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);

Scroll to Top

Discover more from CODE t!ps

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

Continue reading