Added a couple of convenience methods on NSString (OS X 10.5 compatibility).

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29810 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2010-02-28 23:37:22 +00:00
parent 3a49540942
commit 08c1acb850
2 changed files with 28 additions and 0 deletions

View file

@ -280,6 +280,12 @@ typedef NSUInteger NSStringEncodingConversionOptions;
- (id) initWithContentsOfFile: (NSString*)path - (id) initWithContentsOfFile: (NSString*)path
usedEncoding: (NSStringEncoding*)enc usedEncoding: (NSStringEncoding*)enc
error: (NSError**)error; error: (NSError**)error;
- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace
withString: (NSString*)by
options: (NSStringCompareOptions)opts
range: (NSRange)searchRange;
- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace
withString: (NSString*)by;
#endif #endif
- (id) initWithCharactersNoCopy: (unichar*)chars - (id) initWithCharactersNoCopy: (unichar*)chars
length: (NSUInteger)length length: (NSUInteger)length

View file

@ -1614,6 +1614,28 @@ handle_printf_atsign (FILE *stream,
return array; return array;
} }
- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace
withString: (NSString*)by
options: (NSStringCompareOptions)opts
range: (NSRange)searchRange
{
id copy = [self mutableCopy];
[copy replaceOccurrencesOfString: replace
withString: by
options: opts
range: searchRange];
return [copy makeImmutableCopyOnFail: NO];
}
- (NSString*)stringByReplacingOccurrencesOfString: (NSString*)replace
withString: (NSString*)by
{
return [self
stringByReplacingOccurrencesOfString: replace
withString: by
options: 0
range: NSMakeRange(0, [self length])];
}
/** /**
* Returns a substring of the receiver from character at the specified * Returns a substring of the receiver from character at the specified
* index to the end of the string.<br /> * index to the end of the string.<br />