I am using ARC with TWRequest. I have successfully returned a search from twitter and created an array of the results. Here is my code…
NSArray *results = [dict objectForKey:@"results"];
//Loop through the results
NSMutableArray *twitterText = [[NSMutableArray alloc] init];
for (NSDictionary *tweet in results)
{
// Get the tweet
NSString *twittext = [tweet objectForKey:@"text"];
// Save the tweet to the twitterText array
[twitterText addObject:twittext];
}
NSLog(@"MY ************************TWITTERTEXT************** %@", twitterText );
My question is, I want to use twitterText later in the .m file under cellForRowAtIndexPath but as soon as the loop through (as above) is finished it is being released under ARC.
I have set the property as strong in my .h file (as well as declaring it above just prior to the loop – not sure if I can do that but if I do not declare in as above the twitterText returns NULL).
Printing a log straight after the loop through as above prints the twitterText Array fine but the same Log in cellForRowAtIndex path method returns a blank, almost like it has forgotten it exists. Any help would be appreciated. Thanks. Alan
You are declaring your variable twitterText in a local context. So ARC is dropping it after the method is done. You should have it declared like this if you’d like to use it outside the scope of that method.