2011-10-23 32 views
0

同期要求または非同期要求のいずれかを要求することはできますか?それは、その要求のデータを返すようiPhone SDKの同期要求または非同期要求

NSURL *imageURL = [NSURL URLWithString:@"http://sampleRequest.com/request`enter code here`"]; 
     NSData *data = [NSData dataWithContentsOfURL:imageURL]; 
     UIImage *image = [[UIImage alloc] initWithData:data]; 

     [tempElement setImage:image]; 

答えて

0

+[NSData dataWithContentsOfURL:]方法は、同期要求をトリガします。これは、要求が完了するまでスレッドをブロックする同期要求でのみ可能です。

非同期リクエストを希望する場合は、NSURLConnectionを参照してください。具体的には、+[NSURLConnection connectionWithRequest:delegate:]が必要です。 delegateを実装する必要があります。 Using NSURLConnection guideをご覧ください。

関連する問題