I am not able to add objects to a simple NSMutableArray. I have an objective-c reference next to me and have it working for simple string. But I need to add actual objects. Please tell me what I am doing wrong here.
Code:
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]);
Returns this in log as it loops through two objects:
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
Actually the array seems to not fill up at all (considering count:0)
Thanks for the help
I found the problem!
I didn’t initialize the array like so: