我有一个int,由于某种原因它不工作后16左右。这里是我的代码:cocoa:NSString不删除所有字符
NSArray *sortedArray;
sortedArray = [doesntContainAnother sortedArrayUsingFunction:firstNumSort context:NULL];
int count2 = [sortedArray count];
//NSLog(@"%d", count2);
int z = 0;
while (z < count2) {
NSString *myString = [sortedArray objectAtIndex:z];
NSString *intstring = [NSString stringWithFormat:@"%d", z];
NSString *stringWithoutSpaces;
stringWithoutSpaces = [[myString stringByReplacingOccurrencesOfString:intstring
withString:@""] mutableCopy];
[hopefulfinal addObject:stringWithoutSpaces];
NSLog(@"%@", [hopefulfinal objectAtIndex:z]);
z++;
}
编辑:这不是int,这是stringWithoutSpaces线...我无法弄清楚什么导致了它。
所以它(的NSLog,看到的Z ++以上)看起来是这样的:
“这里的”
“无所谓”
“17 whatevere”
“18本”
等
也许你可以告诉我们你有什么(你的输入数据)和你想达到什么目的。 – stefanB 2009-12-09 03:25:07
根据我对你的代码的理解,你正在将char转换为一个ascii值的字符串,然后我不确定你要替换什么,因为该行不完整。 – stefanB 2009-12-09 03:29:01
你为什么做一个可变的副本?你不要改变字符串。另外,你泄漏它。 – 2009-12-09 06:45:31