哪里出现错误了,求指点。
+ (NSString *)reversePrint:(NSString *)str
{
NSMutableString *str1 = [[NSMutableString alloc] initWithString:str];
NSUInteger count = str.length;
for (int i = 0; i <= (count/2 - 1); i++)
{
char left = [str characterAtIndex:i];
char right = [str characterAtIndex:(count - i - 1)];
NSString *newright = [[NSString alloc] initWithFormat:@"%c", left];
NSString *newleft = [[NSString alloc] initWithFormat:@"%c", right];
[str1 stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:newleft];
[str1 stringByReplacingCharactersInRange:NSMakeRange((count - 1 - i), 1) withString:newright];
}
return str1;
} |
|