Cache Facebook Profile Picture iOS -


i'm saving images disk app users, either upload picture or connect facebook , display profile picture.

this works great, if user changes facebook profile picture, code below never updates image.

how can check facebook graph api check if image has been uploaded without redownloading image? using afnetworking checking 302 header option if possible-just not sure how implement.

//load image if exists on disk      nsfilemanager *filemanager = [nsfilemanager defaultmanager];     nsstring *documentspath = [nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) firstobject];     nsstring *filepath = [documentspath stringbyappendingpathcomponent:uniquecustomerpath];     bool fileexists = [filemanager fileexistsatpath:filepath];     if(fileexists){         uiimage* tempimage = [uiimage imagewithcontentsoffile:filepath];         completionhandler(tempimage);     }  //download image if not     else{                             nsstring *imageurl=[nsstring stringwithformat:@"https://graph.facebook.com/%@/picture?type=large", (long)self.customer.facebook_id];             uiimage *tempimage = [uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:imageurl]]];             nsdata *mydata = uiimagejpegrepresentation(tempimage, 1);                             [mydata writetofile:filepath atomically:yes];             completionhandler(tempimage);         } 


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -