dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
非同期 .. 処理は止まらないがdispatch内処理後数十秒経ってからUIViewが更新される
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
同期 .. dispatch内処理中はフリーズしてしまう
UIView更新の時だけdispatch_sync dispatch_get_main_queue使う
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError* error = nil;
NSString* url=[NSStringstringWithFormat:@"http://"];
NSURLRequest* request = [NSURLRequestrequestWithURL:[NSURLURLWithString:url] cachePolicy:NSURLRequestReloadIgnoringCacheDatatimeoutInterval:5.0];
NSData* data = [NSURLConnectionsendSynchronousRequest:request returningResponse:nilerror:&error];
if (!i) {
dispatch_sync(dispatch_get_main_queue(), ^{ // mainキューでしかUIViewは更新されないので、更新される瞬間だけmainキューで処理
imagee[i].image = [UIImageimageWithData:data];
[self.draggableViewaddSubview:imagee[0]];
[self.draggableViewreloado];
});
} else
if (i==1) {
dispatch_sync(dispatch_get_main_queue(), ^{
imagee[i].image = [UIImageimageWithData:data];
[self.hakooaddSubview:imagee[1]];
});
} else {
imagee[i].image = [UIImageimageWithData:data];
}
});