//将s中每个字母大写变成小写,小写变成大写,其他字符不动。返回值是修改后的字符串
-(NSString *)reversalUpperAndLowerForString:(NSString *)s
{
NSMutableString *str=[[NSMutableString alloc]init];
for (int i=0; i<s.length; i++) {
NSString *subStr=[s substringWithRange:NSMakeRange(i, 1)];
unichar j=[subStr characterAtIndex:0];
if ((j>='a')&&(j<='z')) {
[str appendString: [subStr uppercaseString]];
}
else if((j>='A')&&(j<='Z'))
{
[str appendString: [subStr lowercaseString]];
}
else
{
[str appendString:subStr];
}
}
return str;
}
+(void)test
{
NSString *str=@"hello123WORD";
Reight *eig=[[Reight alloc]init];
NSString *substr= [eig reversalUpperAndLowerForString:str];
NSLog(@"%@",substr);
}