Is there anything similar to an indexOf function in the NSString objects?
I wrote a category to extend original NSString object. Maybe you guys can reference it. (You also can see the article in my blog too.)
ExtendNSString.h:
#import
@interface NSString (util)
- (int) indexOf:(NSString *)text;
@end
ExtendNSStriing.m:
#import "ExtendNSString.h"
@implementation NSString (util)
- (int) indexOf:(NSString *)text {
NSRange range = [self rangeOfString:text];
if ( range.length > 0 ) {
return range.location;
} else {
return -1;
}
}
@end