你好,我的问题是我的NSURLConnection的委托方法没有被调用,我读了其他有同样问题的帖子,但我不能解决这个问题。
@implementation firstViewController
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[sendData sendValues];
});
end
other class
@interface SendInformation //this class extend NSObject<NSURLConnectionDataDelegate>
-(void)sendValues{
.......
NSURLConnection *conn = [[NSURLConnection alloc] init];
(void)[conn initWithRequest:request delegate:self];
}
end连接正在工作(我在SendInformation.m中有所有的委托方法)问题是我从来没有得到过响应,我读到你需要在主线程中运行连接,但如果我这样做了,接口将被冻结,直到连接完成,我希望NSURLConnection在不同的类中。
发布于 2013-05-02 00:23:02
您用于创建连接的代码很奇怪。您需要:
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];当然,self必须实现所有适当的NSURLConnectionDelegate方法。
https://stackoverflow.com/questions/16321882
复制相似问题