In Objective-C, in the definition of a subclass (perhaps in the interface file), is it possible to cast an instance variable (ivar) that's inherited from the super class?
I want to do this because I've defined the superclass's ivar as NSObject *session
, and I want to cast the subclasse's ivar to Facebook *session
, so that I don't have to cast it every time I'm sending it a message that Facebook
instances respond to but NSObject
instances don't.
There is no way to change the type of a superclass interface variable, one thing you could do is to add a getter method, such as
- (Facebook *) getSession {
return (Facebook *)[self session];
}