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
Post a Comment