我已经去了一圈又一圈,我一直在试图用这个例子 ,但运行到委托方法的麻烦。 我试图找出如何关闭了这一点。 看起来我有设置了很多正确的,但需要在最后一步的帮助:
我得到一个 - [ThirdTab apiFinished:]:无法识别的选择发送到实例。
在WebServiceAPI.m两线:self.aDelegate = aDelegate是给我一个错误:2)aDelegate局部声明隐藏实例变量。
这是我第一次去周围使用像这样的代表无法弄清楚这个错误。
谢谢。
这是我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];
这是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
这里是我所遇到的问题的WebServiceAPI.m:
- (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;
}