Reputation: 2552
For example:
NSString *sentence = @"My name is Roman";
NSString *name = @"Roman";
Is there way to delete name
's text from sentence
string?
Upvotes: 0
Views: 148
Reputation: 1333
Alternatively, you can use substringWithRange:
like so:
NSString *finalString = [sentence substringWithRange:NSMakeRange(3, 16)];
Upvotes: 1
Reputation: 3359
Yes
sentence = [sentence stringByReplacingOccurrencesOfString:name withString:@""];
Upvotes: 8
Reputation: 20163
NSString* result = [sentence stringByReplacingOccurrencesOfString:name withString:@""];
Upvotes: 10