I keep getting this error when trying to access the textfield value of my view:
error: request for member 'inputAnswer' in something not a structure or union
The UITextField is declared as follows:
@interface TextInputQuestionViewController : UIViewController {
Question *question;
IBOutlet UILabel *questionTitle;
IBOutlet UILabel *inputLabel;
IBOutlet UITextField *inputAnswer;
}
@property (nonatomic, retain) UILabel *questionTitle;
@property (nonatomic, retain) UILabel *inputLabel;
@property (nonatomic, retain) Question *question;
@property (nonatomic, retain) UITextField *inputAnswer;
I am trying to access the textfield as follows (as it is nested):
NSLog(@"%@", currQ.question.inputAnswer.text);
What am I doing wrong?
Update: @sergio you are right, I did mean that but it still throws this error. I’m sure its pointing at the right place too…
//pushes new view onto navigation controller stack
-(void) switchViews:(id)sender{
if(currQNum < [questionArray count] - 1){
if(currQNum > 0){
Answer* ans = currQ.question.answer;
ans.questionId = currQ.question.qId;
ans.entryId = @"1";//temporary;
//if else for different input types
NSString* qt = currQ.question.qType;
if([qt isEqualToString:@"Slider"]){
ans.answer = currQ.sliderLabel.text;
}else if([qt isEqualToString:@"Option"]){
}else if([qt isEqualToString:@"TextInput"]){
NSLog(@"%@", currQ.inputAnswer.text); //PROBLEM
//ans.answer = currQ.inputAnswer.text;
}else if([qt isEqualToString:@"ImagePicker"]){
}else{
}
[answerArray addObject: ans];
[ans release];
}
[self startQuestion:currQNum isLast:FALSE];
currQNum++;
}else{
Answer* ans = currQ.question.answer;
ans.questionId = currQ.question.qId;
ans.answer = currQ.sliderLabel.text;
ans.entryId = @"1";//temporary;
[answerArray addObject: ans];
[ans release];
//store data temporarily - section finished
[self startQuestion:currQNum isLast:TRUE];
currQNum++;
}
}
Possibly you meant:
The error message:
means that the compiler cannot recognize
currQas a structure or a union (or an Objective-C object).