连接字符串

时间:2010-02-23 14:27:32

标签: objective-c

NSMutableArray * oneText = [[NSMutableArray alloc] init];
[oneText addObject:[arraySystem objectAtIndex:[countImage intValue]]];
[oneText addObject:@".png"];
NSString *oneTextText=[oneText objectAtIndex:0];
[oneTextText stringByAppendingString:[oneText objectAtIndex:1]];
NSLog(oneTextText);

为什么上面的代码不能打印'Length.png'?因为[arraySystem objectAtIndex:[countImage intValue]]等于'长度' 它只打印'长度'

1 个答案:

答案 0 :(得分:4)

在调用stringByAppendingString时输入“oneTextText =”,它应该是:

oneTextText = [oneTextText stringByAppendingString:[oneText objectAtIndex:1]];