cachingFacebook个人资料图片iOS

我正在将图片保存到磁盘,以供我的应用用户使用,他们要么上传图片,要么与Facebook连接,然后显示他们的个人资料图片。

这很好,但如果用户更改他们的脸谱资料图片,下面的代码永远不会更新图像。

我怎样才能检查facebook graph api检查是否已经上传图像没有重新下载图像? 我正在使用AFNetworking所以检查302头是一个选项,如果可能 – 只是不知道如何实现。

 //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); }