Reputation: 2455
If I want to delete a value from the NSString @"this is my book", what should I use?
The return value I want is @"this is book".
Upvotes: 1
Views: 6108
Reputation: 382
You can use NSRange
NSString *string = @"lorem ipsum dolor sit amet";
NSRange range = [string rangeOfString:@"ipsum"]; // {.location=6, .length=5}
NSString *substring = [string substringWithRange:
Upvotes: -2
Reputation: 14118
NSString *myString = @"this is my book";
myString = [myString stringByReplacingOccurrencesOfString:@" my " withString:@" "];
Hope this helps
Upvotes: 9