I went around and around, I tried to use this example , but ran into a problem in the delegate method. I am trying to figure out how to close this. It looks like I'm set up correctly, but you need help in the last step:
I get - [ThirdTab apiFinished:]: an unrecognized selector sent to the instance.
On line 2, WebServiceAPI.m: self.aDelegate = aDelegate gives me an error: 2) The local aDelegate declaration hides the instance variable.
This is my first approach using delegates who cannot understand this error.
Thank.
This is in my third type of UITableViewController:
-(void)viewDidLoad {
[super viewDidLoad];
WebServiceAPI *api = [[WebServiceAPI alloc] init];;
api.delegate =self;
[api DataRequest:data3 delegate:self];
self.tableDataSource3 = [data3 objectForKey:@"Rows"];
self.webApi = api;
[api release];
This is WebServiceAPI.h:
#import <UIKit/UIKit.h>
@class WebServiceAPI;
@protocol WebServiceAPIDelegate;
@interface WebServiceAPI : NSObject
{
id<WebServiceAPIDelegate>aDelegate;
NSDictionary *data3;
NSArray *rowsArrayFamily;
NSMutableData *receivedData;
NSString *jsonreturnFF;
}
@property (nonatomic, assign) id<WebServiceAPIDelegate>aDelegate;
@property (nonatomic, retain) NSDictionary *data3;
@property (retain,nonatomic) NSArray *rowsArrayFamily;
@property (nonatomic, retain) NSMutableData *receivedData;
@property (nonatomic, retain) NSString *jsonreturnFF;
- (void) DataRequest: (id) aDelegate;
@end
@protocol WebServiceAPIDelegate
@required
-(void)apiFinished:(WebServiceAPI*)api;
-(void)api:(WebServiceAPI*)api failedWithError:(NSError*)error;
@end
Here is WebServiceAPI.m where I have a problem:
- (void) DataRequest:data3 delegate:(id) aDelegate; {
self.aDelegate = aDelegate;
NSUserDefaults *defaultsF = [NSUserDefaults standardUserDefaults];
NSString *useridFF = [defaultsF objectForKey:kUseridKey];
NSString *urlstrF = [[NSString alloc] initWithFormat:@"http://www.~.php?userid=%@",useridFF];
NSURLRequest *req3 =[NSURLRequest requestWithURL:[NSURL URLWithString:urlstrF]];
NSURLConnection *conn3 = [[NSURLConnection alloc] initWithRequest:req3 delegate:self];
NSMutableData *data =[[NSMutableData alloc] init];
self.receivedData = data;
}