I have a dynamically typed member id currentEvent
in my view controller class. The rationale is that the view controller is used to display data for two model classes that are very similar.
I have a setter:
-(void)setCurrentEvent:(id)e {
[self.currentEvent release];
Class eventClass = [e class];
currentEvent = [[eventClass alloc] init];
currentEvent = [e retain];
}
Now I want to access a member of the class:
return [currentEvent.comments count];
But the compiler complains: request for member 'comments' in something not a structure or union
.
I am afraid I have a fundamental misconception about dynamic typing, but I hope it's something much simpler.