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

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

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -