Hey all,
I want to use the Twitter framework + some tableview to show data.
1) click button to get 2 last posting
2) use a segue to show the raw data
3) use navigation bar to return to tabbars...
I have the storyboard design in the picture attached
here's the problem:
The segue is being called before the post request is processed (that's what I deduced from debugging the code)! (in essence the dictionary has no data as the segue is called!!!
PS: the twitter code comes out of the twitter framework sample and SBJson...
any chance someone has played with the xcode4.2 to help me understand how to slow or make the call in another way??
Code:
-(void) getUserTimeLine{
TWRequest *postRequest = [[TWRequest alloc] initWithURL:[NSURL URLWithString:@"https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=USERNAME&count=1"] parameters:nil requestMethod:TWRequestMethodGET];
[postRequest performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
NSString *output;
if ([urlResponse statusCode] == 200) {
// Parse the responseData, which we asked to be in JSON format for this request, into an NSDictionary using NSJSONSerialization.
NSError *jsonParsingError = nil;
NSDictionary *publicTimeline = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&jsonParsingError];
output = [NSString stringWithFormat:@"HTTP response status: %i\nPublic timeline:\n%@", [urlResponse statusCode], publicTimeline];
NSString *json_string = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
SBJsonParser *parser = [[SBJsonParser alloc] init];
NSDictionary *myDict = [parser objectWithString:json_string error:nil];
[parser performSelectorOnMainThread:@selector(self) withObject:json_string waitUntilDone:YES];
}
else {
output = [NSString stringWithFormat:@"HTTP response status: %i\n", [urlResponse statusCode]];
}
[self performSelectorOnMainThread:@selector(displayText:) withObject:@"Get My Timeline Done" waitUntilDone:NO];
}];
}