so in Objective-C I can have a reference to object that implements certain protocol like this:
I could have a reference to some class, like this:
I was wondering, what should I do to have reference to MyAwesomeClass, or any sub-class.
I could of course just use
id but I'd like to know if there is any better way.
To have reference to an object of your class or its subclasses you still can write
In general it is better to use
NSObject* instead of
id. All objective-C objects are decendants for
NSObject so why ignore all the
If you are dealing with
MyAwesomeClass or subclasses I would use
MyAwesomeClass *object. If you are just using the protocol methods (in the context of the protocol) then I would use
NSObject <MyAwesomeProtocol> *object.