uiimage - Fetch image from url in iOS -


i'm trying fetch image url , show in imageview. image encoded in base64encoded data. using following code it

uiimage *image = [uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:url scale:2.0];  [imageview setimage: image]; 

can 1 suggest problem in it.

one strong possibility datawithcontentsofurl failed whatever reason. should use datawithcontentsofurl:options:error: instead , perform error handling.

edit:

in fact, shouldn't use nsdata methods @ downloading image data. apple docs state suitable local resources , recommend use nsurlsession method when downloading: (nsurlsessiondatatask *)datataskwithurl:(nsurl *)url completionhandler:(void (^)(nsdata *data, nsurlresponse *response, nserror *error))completionhandler


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -