Remplacer char dans NSString
-
01-10-2019 - |
Question
Je veux simplement tous occourrencies remplacerai de « + » avec un blanc « » char ... J'ai essayé un certain échantillon énumérés ici, également utilisé NSSMutableString, mais le plantage du programme ... quelle est la meilleure façon de remplacer char d'un autre ?? merci
La solution
Si vous voulez remplacer par une chaîne mutable (NSMutableString) en place:
[theMutableString replaceOccurrencesOfString:@"+"
withString:@" "
options:0
range:NSMakeRange(0, [theMutableString length])]
Si vous voulez créer une nouvelle chaîne immuable (NSString):
NSString* newString = [theString stringByReplacingOccurrencesOfString:@"+"
withString:@" "];
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow