I have a class called “BaseEntry” and some specific classes like “EntryFoo” and “EntryBar” which are subclasses from “Base Entry”.
Now there is a function getEntry which should return a Object which is subclass of BaseEntry. In Java this wouldn’t be a problem but I have no idea how to fix this in Objective-C for iOS.
Thanks for your help!
Alex
The standard way to do this in Objective-C is to just return an object of type ‘id’; think of it as
Objectin Java. However,idis slightly nicer in that you can assign the return value to a typed value without a cast.To clarify, your options are: