How To Remove and Replace String within a String.

// Here We Deleting Something
NSString *content = @”i am a good boy”;
NSCharacterSet *deleteString = [NSCharacterSet characterSetWithCharactersInString:@”good”];
content = [[content componentsSeparatedByCharactersInSet: deleteString] componentsJoinedByString: @””];
NSLog(@”String===>>>%@”, content);

// Here We Replace Something
NSString *replaceString = @”i am a good boy”;
replaceString = [replaceString stringByReplacingOccurrencesOfString:@”boy” withString:@”Man”];
NSLog(@”Replace String===>>>%@”, replaceString);


Discover more from mycodetips

Subscribe to get the latest posts sent to your email.

Discover more from mycodetips

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top