In Objective-C / Cocoa to grab a substring from an NSString based on beginning and ending characters is easy. This is helpful if you want to parse HTML, JSON, or a REST statement returning. See below:
NSString *sStr = [NSString stringWithFormat:@"%@", assetGroups[indexPath.row]];
NSString *name= [[[[sStr componentsSeparatedByString:@"Beginning Char(s)"] objectAtIndex:1] componentsSeparatedByString:@"End Char(s)"] objectAtIndex:0];
NSString *newString
= [NSString stringWithFormat:@"%@", name];
No comments:
Post a Comment