Follower Count Label not updated for current user while database is correct

66 Views Asked by At

Let me bring 2 views for this issue: one is MyProfile View; two is UserProfile View. Under UserProfile View, there's no problem showing correct follower count in a UILabel updated from user database table but there comes a problem in MyProfile View. follower count in a UILabel cannot be updated despite the table updated correctly. Below is my code in MyProfile View:

// display followers count label ??????? can't be updated .. need to logout and login again ??????
NSInteger followersCount = [[[PFUser currentUser] objectForKey:@"followers"] count];
followersCountLabel.text = [@(followersCount) stringValue];

But this can be resolved by logout and login again. However this is definitely not practical. I use the same code for follower count in UserProfile View but change [PFUser currentUser] to userPassed (which is passed from another view,let's call it Home View, when I tap a username). What I'm trying to tell is if I login to another user and tap my username from Home View, it will go to UserProfile View and my follower count is correct unlike I check from MyProfile View with login as myself.

I'm now doubting about cache things for current user but I'm not familiar with it, so really need help here. But it'd be something else that causes. Any advice?

1

There are 1 best solutions below

1
On BEST ANSWER

I found a solution by simply putting this line: [[PFUser currentUser] fetch];