Xcode debugger not showing my instance variables!!

I hate asking questions like this.


I set a breakpoint in an IBAction method 'pushed:' inside FooViewController. At runtime I pressed a GUI button and processing stopped in pushed:.


In the data-viewing pane of xcode, I see


{code}

self = (FooViewController *) 0x... etc.

{code}


Indented under this is


{code}

UIViewController = (UIViewController) { ...

{code}


Nowhere do I see any of my instance variables!!


Now, they were synthesized from properties, but that doesn't matter, does it?


The code that proceeds to set some instance variables runs fine.


Why isn't xcode displaying self's instance vars?


Thanks,

Chap

Posted on May 13, 2011 12:48 PM

Reply
8 replies
Sort By: 

May 13, 2011 2:00 PM in response to xnav

Yes, yours looks like I was expecting mine to look.


Note that viewDidLoad (below) does work correctly, producing the expected results in the simulator!


Hangman3ViewController.h:


@interface Hangman3ViewController : UIViewController {

}


@property ( nonatomic ) NSInteger wordLength;

@property ( retain, nonatomic ) NSString *alphabet;

@property ( nonatomic ) unichar guess;

@property ( nonatomic ) NSInteger guessNo;

@property ( retain, nonatomic ) NSMutableString *board;


@property ( retain, nonatomic ) IBOutlet
UILabel *boardLabel;

@property ( retain, nonatomic ) IBOutlet
UILabel *guessNumberLabel;

@property ( retain, nonatomic ) IBOutlet
NSArray *keyboardButtons;


- (IBAction)letter:(id)sender;

- (void)showBoard;


@end

and, Hangman3ViewController.m:


#import "Hangman3ViewController.h"


@implementation Hangman3ViewController


@synthesize wordLength = _wordLength; // preprocessor command to gen getter/setter and instance variable

@synthesize boardLabel = _boardLabel; // preprocessor command to gen getter/setter and instance variable

@synthesize guessNumberLabel = _guessNumberLabel; // Guess #n

@synthesize keyboardButtons = _keyboardButtons; // array of buttons

@synthesize alphabet = _alphabet; // A-Z unichars

@synthesize guess = _guess; // unichar

@synthesize guessNo = _guessNo; // int

@synthesize board = _board;


- (IBAction)letter:(id)sender

{

/*

Get letter from sender - driven when key button is pressed.

The button's tag is an int from 0-25, identifying what letter of the alphabet it is.

Extract that unichar from ALPHABET as 'guess'. Then, disable the button,

which has been defined to have its text turn white (invisible) when disabled.

*/

UIButton *button = (UIButton *)sender;

self.guess = [self.alphabet characterAtIndex: button.tag];

NSLog(@"Received keystroke: %C", self.guess);

[button setEnabled:NO];

}


- (void)showBoard

{

self.boardLabel.text = self.board;

self.guessNumberLabel.text = [NSStringstringWithFormat:@"Guess #%d", self.guessNo];

}


- (void)dealloc

{

[_boardLabelrelease];

[_guessNumberLabelrelease];

[_keyboardButtonsrelease];

[super dealloc];

}


- (void)didReceiveMemoryWarning

{

// Releases the view if it doesn't have a superview.

[superdidReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.

}


#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad

{

NSLog(@"Hello from viewDidLoad");

[superviewDidLoad];

self.alphabet = @"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; // unichar string

self.wordLength = 7; // temp - will be set from flipside later on

self.guessNo = 1;

[self.boardsetString:@"_______"]; // actually dynamic based on wordLength

self.board = @"_______";

[selfshowBoard];

}


- (void)viewDidUnload

{

[superviewDidUnload];

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

// Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationPortrait);

}


@end

Reply

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Xcode debugger not showing my instance variables!!

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.