可能重複:
Objective-C: How do you append a string to an NSMutableString?的NSMutableString追加不工作
我有一個NSMutableArray的。我想提取此NSMutable數組的所有元素並將其附加到一個字符串中。我的下面的代碼不起作用。字符串不附加到變量。另外我在這個項目中使用自動引用計數功能。
NSMutableString *theString = [NSMutableString string];
for(int i=0; i<[self.incomingMessages count]; i++) {
id object = [self.incomingMessages objectAtIndex: i];
[theString appendString:(NSString*)object];
}
NSLog(@"the appended string: %@", theString);
[self.incomingMessages removeAllObjects];
如何將存儲的字符串追加到theString變量中。我做了什麼錯誤?
什麼是錯誤信息? – Pfitz
Same as:http://stackoverflow.com/questions/1614481/objective-c-how-do-you-append-a-string-to-an-nsmutablestring –
Ast他指出,可能有一個分配問題。 –