views:

18

answers:

1

Hi all, getting myself confused with NSString's various range methods and where and when they should be used.

I have a random string. Somewhere in the string it may (or may not) contain an identifier such as "Customer Name:" (the quotes will not be included.)

Problem: I need a new string where everything up to and including "Customer Name:" has been removed from the original string.

Any advice is appreciated.

Mac OS X 10.4 compatibility required, manual GC.

+1  A: 
NSRange range = [str rangeOfString:@"Customer Name:"];
NSString *newStr = [str substringFromIndex:range.location + range.length];
Wevah
Thank you very much! Along with a check on the range result, that works great. Cheers.
SirRatty