我無法將對象添加到簡單的NSMutableArray。我在我旁邊有一個Objective-c引用,並且它爲簡單的字符串工作。但我需要添加實際的對象。請告訴我我在這裏做錯了什麼。爲什麼我的對象不被添加到數組中?
代碼:
TBXMLElement *hubImage = [TBXML childElementNamed:@"image" parentElement:[TBXML childElementNamed:@"images" parentElement:pieceXML]];
if(hubImage) {
do {
HubPieceImage *tmpImage = [[HubPieceImage alloc] initWithXML:hubImage];
[self.images addObject: tmpImage];
HubPieceImage *tmpImage2 = [self.images lastObject];
NSLog(@"image : %@", tmpImage.asset_url);
NSLog(@"image 2: %@", tmpImage2.asset_url);
} while ((hubImage = hubImage->nextSibling));
}
NSLog(@"count : %i", [self.images count]);
返回此日誌,因爲它遍歷兩個對象:
image : http://farm6.static.flickr.com/5215/5533190578_4v629a79e5.jpg
image 2: (null)
image : http://farm3.static.flickr.com/2774/5416668522_fdcr19aed3.jpg
image 2: (null)
count : 0
其實陣列似乎根本不填滿(考慮數:0)
感謝您的幫助
是什麼self.images實施什麼樣子的? – servn 2011-05-15 07:04:38