Thanks to Lock a NSMutableArray of an object but not the rest of my object when using GCD I have a user object that populates an array of locations via gcd at init in the hope that by the time we modally get to LocationViewController the locations are present in user.locations
(where user is passed along the viewcontrollers), if they aren't there then I simply display 'loading...' in the picker.
I would ideally like to force a refresh from within the gcd of user in the dispatch_sync
method. I can added a method to LocationViewController that will refresh the picker etc but I'm not sure how to then safely access this.
My first thought was in LocationViewController if the locations aren't there (i.e. nil) then to set a reference to this LocationViewController in user. Within the dispatch_sync
I could then call the method [locCont mymethod]
if locCont isnt nil. But I'm not sure how to set up the property in the user class?
@property (strong, nonatomic) LocationsViewController * locCont;
What worries me is a user can at anypoint logout and return to the root view. I'll then set
user.locCont = nil
will ARC sort any hungover memory nicely?
My other concern is what will happen if they don't choose to set a location and are on a later view. I guess I could handle that by setting user.locCont
to nil in a prepareforsegue
.
Is there a better way to get the LocationsViewController to refresh if the user has got there?