[myString substringToIndex:index];
[myString substringFromIndex:index];
Extract the substring from beginning to the particular position:
NSRange end = [longString rangeOfString:@";"];
NSString *shortString =[longString substringWithRange:NSMakeRange(0, end.location)]];
NSLog("%@", shortString);
Extract a string between two characters:
NSRange start = [longString rangeOfString:@"("];
NSRange end = [longString rangeOfString:@")"];
NSString *shortString = [longString substringWithRange:NSMakeRange(start.location, end.location)]];
NSLog("%@", shortString);
Thanks
ReplyDelete