0

I'm a bit confused. I have 2 classes, an app delegate and a view controller. In my app delegate I get some data via this method:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];

NSDictionary *results = [responseString JSONValue];

NSArray *allTweets = [results objectForKey:@"results"];

[viewController setTweets:allTweets];
[window addSubview:viewController.view];
[window makeKeyAndVisible];

}

and in my view controller I have a button that should reload the data...I've tried a few things such as

Twitter_SearchAppDelegate *appDelegate= (Twitter_SearchAppDelegate *)[[UIApplication sharedApplication] delegate];
    [appDelegate connectionDidFinishLoading];

but none worked...am I going about this in the wrong way? I just want to be able to call the method that loads the data in the first place from the app delegate to the view controller. Any help is appreciated!

4

2 回答 2

0

Yes, you are going in the wrong direction.

You are trying to call the NSURLConnection delegate method your self (wrong). If you want to simply reload the JSON data, you should call in your App Delegates method that initiates the download request to force in the data reload!

于 2012-05-02T08:56:05.933 回答
0

first of all , if i'm not wrong , connectionDidFinishLoading is a delegate method which is triggered when you start the connection process. have you test that your application enters connectionDidFinishLoading ?

in addition when you evaluate your array/dictionary as source to your tableview , did you call again ["your-table-view-name" reloadData] ?

hope this helps..

于 2012-05-02T08:56:59.360 回答