I’m developing a Twitter app and I’m having problems with adding tweets to an NSArray. The problem is I get the tweets, and all the content ok, but the last query i got is just for control, so it doesn’t contains the object “tweet” (which is the tweet content). I have tried stopping it if it detects the control query but no luck. This is the normal search query:
See dictionary: {
"created_at" = 1305363612;
"from_user" = IamDeShayDenise;
"from_user_id" = 123375840;
"from_user_id_str" = 123375840;
geo = "";
id = 69326131068813312;
"id_str" = 69326131068813312;
"iso_language_code" = en;
metadata = {
"result_type" = recent;
};
"profile_image_url" = "http://a3.twimg.com/profile_images/1336852311/110302-003005_normal.jpg";
source = "web";
"source_api_request_type" = 33;
text = "@LondonBlackk Yeah....and Yes I was With My Mommy and Nana!!! && Still Pulling All The Guys...LoL";
"to_user" = LondonBlackk;
"to_user_id" = 172117314;
"to_user_id_str" = 172117314;
}
In that one I get the text object ok and I can read it. The problem comes when I get this:
See dictionary: {
"source_api_request_type" = 33;
}
Or this:
See dictionary: {
"completed_in" = "0.027116";
"max_id" = 69324964586725376;
"max_id_str" = 69324964586725376;
"next_page" = "?page=2&max_id=69324964586725376&q=lol";
page = 1;
query = lol;
"refresh_url" = "?since_id=69324964586725376&q=lol";
"results_per_page" = 15;
"since_id" = 1;
"since_id_str" = 1;
"source_api_request_type" = 33;
warning = "since_id removed for pagination.";
}
And this is the code I use for filling the arrays:
tweets = [[NSMutableArray alloc] init]; usernames = [[NSMutableArray alloc] init]; for(NSDictionary *d in searchResults) {NSLog(@"See dictionary: %@", d); Tweet *author = [d objectForKey:@"from_user"]; Tweet *tweet = [d objectForKey:@"text"]; if ([d objectForKey:@"from_user"] == nil || [d objectForKey:@"text"] == nil){ NSLog(@"end"); } [usernames addObject:author]; [tweets addObject:tweet]; [author release]; [tweet release]; }I don't know what can be wrong 🙁
Thanks in advance 😀
*UPDATE:*Got it working in this way
if ([d objectForKey:@"from_user"] == nil || [d objectForKey:@"text"] == nil){ NSLog(@"end"); } else { [usernames addObject:author]; [tweets addObject:tweet]; }
instead of:if ([d objectForKey:@"from_user"] == nil || [d objectForKey:@"text"] == nil){ NSLog(@"end"); } [usernames addObject:author]; [tweets addObject:tweet];
Then the other problem was also solved. Thanks y'all!!
The way of solving it is this:
instead of: