在单独的线程上运行代码的最佳方式是什么?NSOperation和NSURLConnection冲突
NSInvocationOperation *operationToComplete = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(operationMethod) object:nil];
NSOperationQueue *queueToStart=[[NSOperationQueue alloc] init];
[queueToStart addOperation:operationToComplete];
-(void) operationMethod
{
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&_response error:&_error];
}
OR:
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request
delegate:self];
我一直在做的第二种方式,但我对此有点迷惑或者用另一种方式来做到这一点。
这沃尔是有帮助的; HTTP://stackoverflow.com/questions/11496063/best-multithreading-approach-in- objective-c – rptwsthi 2013-03-01 06:53:15
是不是你去寻求异步请求.. – Dany 2013-03-01 06:53:23