我不知道如何从connectionDidFinishLoading获得结果。我有这些代码:
connect.m:
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
NSString *result = [[NSString alloc] initWithBytes:[self.dataResponse bytes] length:[self.dataResponse length] encoding:NSUTF8StringEncoding];
}
videos.m:
@property (nonatomic, retain) Connect *connect;
- (void)viewDidLoad
{
self.connect = [[Connect alloc] initWithDelegate:self
onSuccess:@selector(responseSuccess:)
onError:@selector(responseError:)];
}
我想知道我是怎么得到的,在videos.m中是来自connect.m的结果
答案 0 :(得分:0)
connectionDidFinishLoading
告诉你完成了。您需要实施协议NSURLConnectionDataDelegate
并使用connection:didReceiveData:
来收集数据。
请注意,您的数据会以多个块的形式出现,因此connection:didReceiveData:
会被多次调用,您必须继续将新的数据块追加到最后才能调用connectionDidFinishLoading
。< / p>