在單獨的線程上運行代碼的最佳方式是什麼?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