我有一些带有实现和头文件的 Objective-C 类。一个类,它的子类AppDelegate
,有一个方法,如下所示,使用 API 调用获取数据:
@implementation API
- (NSMutableData *)set:(NSString *) API
{
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:GETString]];
self.connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
我还有一些类,它们是 的子类UIViewController
,我从这里调用如下:
- (void)viewWillAppear:(BOOL)animated
{
API *theInstance = [[API alloc] init];
[theInstance set:@"&get=different&call=getAPIMethods"];
}
现在我想从扩展类方法中获取响应数据- (void)connectionDidFinishLoading:(NSURLConnection *)connection
UIViewController
- (void)viewDidAppear:(BOOL)animated
我怎样才能得到回报NSMutableData
?