ios - Run code in the background -


this question has answer here:

i'm trying download image website , save uiimage if user has low connection can take forever... how can download in background user can keep using app in meantime?

here code:

theicon.image = [[uiimage alloc] initwithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:@"http://mywebsite.com/icon.png"]]]; 

use gcd.

dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_background, 0), ^{     // background code     dispatch_async(dispatch_get_main_queue(), ^{         // handling on main thread when done!     }); }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -