@fiy-fish
2015-07-04T18:09:13.000000Z
字数 410
阅读 1889
Objective-c
/*
//将原字符串进行小写转大写,大写转小写
//比如输入 @"aBCdEfGA" 输出 @"AbcDeFga"
+(NSString *)reveserChacter:(NSString*)srcStr;
*/
int main()
{
NSString *str = @"aBCdEfGA" ;
char ch;
NSMutableString *str1 = [NSMutableString string];
for (int i=0; i<str.length; i++) {
ch = [str characterAtIndex:i];
if (ch>='a'&&ch<='z') {
ch=ch-32;
[str1 appendFormat:@"%c",ch];
}
else
{
ch = ch+32;
[str1 appendFormat:@"%c",ch];
}
}
NSLog(@"%@",str);
NSLog(@"%@",str1);
}