
Untitled
By: a guest on
Apr 20th, 2012 | syntax:
None | size: 0.48 KB | hits: 8 | expires: Never
How do I use NSRange with this NSString?
productID = @"com.sortitapps.themes.pink.book";
partialID = @"com.sortitapps.themes.pink.";
NSString *str = @"com.sortitapps.themes.pink.book";
NSUInteger dot = [str rangeOfString:@"." options:NSBackwardsSearch].location;
NSString *newStr =
[str stringByReplacingCharactersInRange:NSMakeRange(dot+1, [str length]-dot-1)
withString:@"something_else"];
[productID stringByDeletingPathExtension];