Hi,
I'm running into a situation where I am initializing a view controller from a nib file and it doesn't seem to properly initialize the UILabel in the nib. I have an IBOutlet UILabel instance variable in my view controller, and after the call to initWithNibName, it comes back with 0x0. The outlet is connected to the UILabel in the nib file in Interface Builder.
Here's my code:
view controller gets initialized during row click of nav controller:
Code:
QuestionViewController *nextController = [[QuestionViewController alloc]
initWithQuestion:nextQuestion];
Here's the code for initWithQuestion:
Code:
if (self = [super initWithNibName:@"QuestionView" bundle:nil])
{
self.myQuestion = initQuestion;
questionTextLabel.text = initQuestion.questionTextString;
[self.questionTextLabel retain];
}
return self;
so when I'm stepping through, after the line "self.myQuestion = initQuestion", the myQuestion property shows up as having a valid address (0x1234 or something)
but the questionTextLabel property shows up as having address of 0x0. So when I try to set its text, nothing happens.
I've declared questionTextLabel in the header file for this view controller with the following statements:
Code:
IBOutlet UILabel *questionTextLabel;
...
@property (nonatomic, retain) IBOutlet UILabel *questionTextLabel;
It was my understanding that the call to initWithNibName should initialize a UILabel object and set my local UILabel pointer to point to that object. Why is this not happening?
Thanks for the help! Let me know if I need to post any more code.