I’m searching Twitter for tweets with this code:
- (void)fetchTweets
{
NSURL *url = [NSURL URLWithString:@"http://search.twitter.com/search.json"];
NSDictionary *params = [NSDictionary dictionaryWithObject:@"#winning" forKey:@"q"];
TWRequest *request = [[TWRequest alloc] initWithURL:url
parameters:params
requestMethod:TWRequestMethodGET];
[request performRequestWithHandler:
^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
if (responseData) {
NSError *jsonError;
tweets =
[NSJSONSerialization JSONObjectWithData:responseData
options:kNilOptions
error:&jsonError];
if (tweets) {
// NSLog(@"%@", tweets);
}
else {
NSLog(@"%@", jsonError);
}
}
[[self delegate] receivedTweets];
}];
[self performSelector:@selector(fetchTweets) withObject:nil afterDelay:30];
The tweets variable is a NSArray and I am trying to put it into a NSDictionary with this code:
NSDictionary *tweet = [[TwitterHandler sharedInstance].tweets objectAtIndex:indexPath.row];
I am definitely getting the JSON text for the tweets but when trying to add them to the dictionary so I can eventually put them into a table I get the “unrecognized selector sent to instance” error.
I am not sure why I am getting this and any help would be appreciated.
This returns an NSDictionary object of the tweets. The Twitter search results from that URL can be filtered out by looking for the content in the key
results.AKA:
Then the tweets can be iterated through since they are in an NSArray.