How would I go about making all characters in an NSString lowercase?
如何让NSString中的所有字符都小写呢?
1 个解决方案
#1
52
NSString has a cunningly named lowercaseString
method.
NSString有一个巧妙命名的小写字符串方法。
NSString *noCaps = [yourString lowercaseString];
Edited to add
编辑添加
If you are asking how to change the actual string to be lowercase - you can't. NSStrings are immutable. They can't be changed after they have been created. If you want to change the string in place you should use an NSMutableString like so:
如果你想知道如何把实际的字符串变成小写的,你不能。nsstring是不可变的。它们在被创建之后不能被更改。如果你想要改变字符串,你应该使用像这样的NSMutableString:
[aMutableString setString:[aMutableString lowercaseString]];
#1
52
NSString has a cunningly named lowercaseString
method.
NSString有一个巧妙命名的小写字符串方法。
NSString *noCaps = [yourString lowercaseString];
Edited to add
编辑添加
If you are asking how to change the actual string to be lowercase - you can't. NSStrings are immutable. They can't be changed after they have been created. If you want to change the string in place you should use an NSMutableString like so:
如果你想知道如何把实际的字符串变成小写的,你不能。nsstring是不可变的。它们在被创建之后不能被更改。如果你想要改变字符串,你应该使用像这样的NSMutableString:
[aMutableString setString:[aMutableString lowercaseString]];