Reputation: 21
I have the following code:
[GetUserData getUserDataWithBlock:^(UserData *userData, NSError *error)
{
self.userData = userData;
#1 self.userData.fbUser = user;
// Call REST API of server 'GetAllWords'
[GetAllWords getAllWordsWithBlock:^(NSSet *newWords, NSError *error)
{
[self saveAllWords:newWords];
#2 [self showRootView];
}];
}];
The problem is, that self.userData
is correctly set in #1 (and is not null), but when I'm getting to #2 - self.userData
becomes null...
Point #1 is the only place where I set self.userData
.
Upvotes: 2
Views: 167
Reputation: 437552
I could imagine the behavior you describe if the userData
property was defined as weak
(notably, if getAllWordsWithBlock
runs asynchronously).
If not, I'd suggest setting up a "watch" on the underlying variable:
setting a breakpoint at point #1 (and at point #2, presumably) in your code and start the app in the debugger;
when the debugger stops at your first breakpoint, add a watch on the variable that backs your userData
property by right-clicking (or control-clicking) on the variable in the "Variables" view and choosing "Watch" (obviously, this screen snapshot is a different piece of code, but it illustrates how to create a "watch" in Xcode):
resuming execution by hitting the continue button:
when you hit a watch breakpoint, sometimes you'll be staring at assembler, but you can hit the "step out" button until you get to a point in your code you recognize.
That can be helpful in identifying what is changing your variable (if not a simple weak
property problem).
Upvotes: 2