0

I am trying to update my profile picture on side menu (MFSideMenu) and as soon as I update profile picture over the web server, I want to set it on my iOS app. URL of the image being the same, I am unable to upgrade it. I guess the problem is that every time I change image, image url being the same is loaded from the cache memory so it doesn't change. Is there any way to download changed image as when it changes without the need to change imageUrl?

In response I always get

imageUrl :"user_image" = "profile/local/images/user_id/myimage"; 

Accordingly I update my model and fetch information from model as I open the side menu.

`func menuAction(){ 
        self.getUserDetails()        
 }

func getUserDetails()  {
NotificationCenter.default.post(name: Notification.Name("NotificationIdentifier"), object: self)
self.menuContainerViewController.toggleLeftSideMenuCompletion(nil)
}`
Daniel F
  • 13,620
  • 2
  • 29
  • 55
Preetika
  • 702
  • 8
  • 21

1 Answers1

0

This may be a quick fix. But this is not the best way.

Add different query parameters to the url when you going to set(download) the image.

For eg: If your image url is http://www.yourserver.com/images/my_image.png then change it to http://www.yourserver.com/images/my_image.png?any_name=timestamp

Suresh
  • 14
  • 4
  • I have tried adding time_stamp but still not able to update image. 'NSString *currentTimeStamp = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]]; NSString *user_profilePic = [NSString stringWithFormat:@"%@?time=%@",[json valueForKeyPath:@"userDetails.user_image"],currentTimeStamp];' – Preetika Jan 16 '18 at 04:26
  • I fixed the issue by firing notification from the app delegate and updating side menu so that whenever application will open , data will be refreshed. – Preetika Jan 16 '18 at 06:57