Hi all! I want simply replace all occourrencies of "+" with a blank " " char... I tried some sample listed here, also used NSSMutableString, but the program crash... what's the best way to replace a char from another?? thanks
+2
A:
If you want to replace with a mutable string (NSMutableString) in-place:
[theMutableString replaceOccurrencesOfString:@"+"
withString:@" "
options:0
range:NSMakeRange(0, [theMutableString length])]
If you want to create a new immutable string (NSString):
NSString* newString = [theString stringByReplacingOccurrencesOfString:@"+"
withString:@" "];
KennyTM
2010-06-29 08:29:30
thankyou! it works fine! I don't know yesterday what was the problem.. now is ok!
ghiboz
2010-06-29 20:55:00
A:
NSString *firstString = @"I'm a noob at Objective-C", *finalString;
finalString = [[firstString stringByReplacingOccurancesOfString:@"O" withString:@"0"] stringByReplacingOccurancesOfString:@"o" withString:@"0"];
Got the code from here!
Bogdan Constantinescu
2010-06-29 08:30:19