Reputation: 451
this is my class
#import "newsFeedController.h"
- (void)viewDidLoad {
//statements
webService = [[WebServiceManager alloc] init];
[webService setDelegate:self];
//am calling the webservicemanager class here
[webService userStatusUpdateGet:@"1" endLimit:@"10" setSessionID:[[UserSession getInstance] SESSION_ID]];
//am printing.....
nslog(@"printing result %@",webService.test);
this test is a array from webServiceManager
class that has to return only after going to
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
method
how do I do this?.Thanks
(am using json request and response)
Upvotes: 0
Views: 210
Reputation: 10548
Create a protocol for your view controllers to conform to, for callbacks when the data is retrieved. The view controller implementation will refresh display as appropriate.
EDIT:
Create a protocol:
@protocol WebServiceDelegate <NSObject>
@optional
- (void) serviceSuccessful: (BOOL)success withData:(NSMutableData*)data;
Create a class with delegate object of this protocol. Also create a method in this class which would be called by your viewController to start setting up the connection:
@interface WebServiceHandler : NSObject {
id <WebServiceDelegate> delegate;}
Write all the connection delegate method implementation in WebServiceHandler class. In connectionDidFinishLoading, set the delegate object:
[[self delegate] serviceSuccessful:YES withData:webData];
Make your viewController conform to WebServiceDelegate protocol and give an implementation to serviceSuccessful method. Now this method would be called in the viewController, as soon as WebServiceHandler class has finished with retreiving data from the connection.
Upvotes: 0
Reputation: 26390
Isn't (void)connectionDidFinishLoading:(NSURLConnection *)connection
a delegate method of WebServiceManager? If yes it should be accessible within your class where you can implement the method's action
Upvotes: 1