I've been going around and around, I've been trying to use this example but running into trouble in the delegate method. I'm trying to figure out how to close this out. Looks like I've got a lot set correctly but need help on final step:
I'm getting a -[ThirdTab apiFinished:]: unrecognized selector sent to instance.
On line two of the WebServiceAPI.m : the self.aDelegate =aDelegate is giving me an error: 2) Local declaration of aDelegate hides instance variable.
This is my first go around with using delegates like this an can't figure out this error.
Thanks.
This is in my ThirdTab UITableViewController:
-(void)viewDidLoad {
[super viewDidLoad];
WebServiceAPI *api = [[WebServiceAPI alloc] init];;
api.delegate =self;
[api DataRequest:data3 delegate:self];
// this is where I'm trying to connect data3 to my tableview.
self.tableDataSource3 = [data3 objectForKey:@"Rows"];
self.webApi = api;
[api release];
This is the 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 the WebServiceAPI.m where I'm having the issue:
- (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;
// self.connection = conn3;
}