I ran it and it's working, but I just want someone to double check that I followed the directions. Any suggestions or corrections will be appreciated.
Assume you have a
NSString *strobject containing some text. Write a code fragment to create a new string with all substrings "aaa" deleted.
NSString *str = @"aaa 123 yes there will be aaaa even more a y a y aaa, "; NSString *str2 = [str stringByReplacingOccurrencesOfString:@"aaa" withString:@""]; NSLog(@"its %@", str2);
Redo when this is
NSMutableString *str, without creating a new object.
NSMutableString *string1 = [NSMutableString stringWithString: @"aaa 123 yes there aaaa even more a y a y aaa,"]; [string1 replaceOccurrencesOfString:@"aaa" withString:@"" options:0 range:NSMakeRange(0, string1.length)]; NSLog (@"string1 = %@", string1); }