Doug Smith
Doug Smith

Reputation: 29316

Why am I not able to print the value of this variable in the debugger?

I have a property of my class called position, which I'm trying to access with self.position.

I get:

(gdb) po self.position
There is no member named position.

But I set my breakpoint at the for loop in the following block. It definitely has a value:

- (IBAction)backFiftyWords:(UIButton *)sender {
    self.position = @([self.position intValue] - 50);

    NSString *wordsToBeShown = @"";

    for (int i = 0; i < [self.numberOfWordsShown intValue]; i++) {

It's an NSNumber.

Upvotes: 2

Views: 148

Answers (1)

Matt Hudson
Matt Hudson

Reputation: 7348

You should use

po [self position] 

Dot syntax doesn't work well with GDB. Upgrading to LLDB/LLVM is a good idea as well.

You can also:

NSLog(@"%@", self.position);

In your code. Or create a breakpoint and edit it, add this is an expression:

expr (void)NSLog(@"%@", self.position)

See this link for more info: http://www.raywenderlich.com/28289/debugging-ios-apps-in-xcode-4-5

Upvotes: 2

Related Questions