I got an array with viewcontrollers from different types, named viewControllersArray so first I check if the type is correct (QuestionViewController) and then I want to print out the property.
for(NSUInteger i = 0; i<viewControllersArray.count; i++) {
if ([[viewControllersArray objectAtIndex:i] isKindOfClass:[QuestionViewController class]]) {
NSLog(@"%@",((QuestionViewController*)[viewControllersArray objectAtIndex:i]).getQAnswer );
}
}
However this just shows me (null) instead of the NSString property.
EDIT
What I got so far is this:
for(NSUInteger i = 0; i<viewControllersArray.count; i++) {
if ([[viewControllersArray objectAtIndex:i] isKindOfClass:[QuestionViewController class]]){
NSLog(@"IDENT: %@", [[viewControllersArray objectAtIndex:i] ident]);
NSLog(@"ANSWER: %@", [[viewControllersArray objectAtIndex:i] getQAnswer]);
}
}
the second NSLog (getQAnswer) works. getQAnswer is a method in QuestionViewController. The first NSLog (ident) shows incorrect output (null), this is the property:
@property (strong, nonatomic) NSString *ident;