ios - Convert String from JSON to UIImage -
i'm receiving json data webservice, includes image represented sting. how can convert string image?
the json data in nsdictionary
, , image data object form "content
"-key:
if let newbannercontentstring = newbanner.objectforkey("content") as? string { let someimage = uiimage(contentsoffile: newbannercontentstring) }
this returns nil
someimage.
if string base64 encoded create nsdata
string , image data.
if let newbannercontentstring = newbanner.objectforkey("content") as? string { let data = nsdata(base64encodedstring: newbannercontentstring, options: nsdatabase64decodingoptions.ignoreunknowncharacters); let someimage = uiimage(data: data!); }
Comments
Post a Comment