views:

21

answers:

1

I have a NSXMLParser that parses YT's API. It then turns all the videos into a class I wrote called video. Then the class is put into an array. Then back at my rootviewcontroller I access xmlParser.allVideos (xmlParser is a class I wrote that is the delegate for the xml parser. Here is what I do with it in the viewDidLoad:

arrayFromXML = xmlParser.allVideos;

Then in the drawing of the tableView I do this:

tempVideo = [arrayFromXML objectAtIndex:indexPath.row];
cell.textLabel.text = tempVideo.videoTitle; //crashes here and says NSString has been deallocated.

How can I fix this?

+1  A: 

If arrayFromXML is an instance variable you have to retain or copy (to be safe from later manipulation) the array as xmlParser simply might not be alive anymore when other methods are called later:

arrayFromXML = [xmlParser.allVideos copy];

Or better yet using a copy or retain property:

self.arrayFromXML = xmlParser.allVideos;
Georg Fritzsche