iphone - How to download and set a UIImage not on the main thread -
i'm adding image web service. how code it's not on main thread? want view load first , image load user doesn't experience slowness when detail view controller loads. what i'm unsure of how add dispatching code. here's code far: nsdata *imagedata = [nsdata datawithcontentsofurl:[nsurl urlwithstring:mainimageurl]]; uiimage *image = [[uiimage alloc] initwithdata:imagedata]; uiview *v = [[uiview alloc] initwithframe:cgrectmake(10, 150, 300, 180)]; uiimageview *iv = [[uiimageview alloc] initwithframe:cgrectmake(0, 10, 300, 180)]; [iv setimage:image]; [_scrollview addsubview:v]; [v addsubview:iv]; and i'm thinking can use threading: dispatch_async( dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ // add code here background processing // // dispatch_async( dispatch_get_main_queue(), ^{ // add code here update ui/send notifications based on // results of background processing }); }); thanks help you can use gcd d...