2

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.

1
  • Is GCD involved here? If so, please provide code for that. Commented Sep 23, 2013 at 0:09

1 Answer 1

2

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):

    add watch

  • resuming execution by hitting the continue button: enter image description here

  • when you hit a watch breakpoint, sometimes you'll be staring at assembler, but you can hit the "step out" button enter image description here 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).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.