In Objective-C, is it possible to restrict id to just a few types? I want to write a method having an id parameter, but this method applies only to some ObjC types: using id could lead to runtime errors. Is there any LLVM convention or something like that?
In Objective-C, is it possible to restrict id to just a few types? I
Share
idis a generic Objective-C object pointer, ie it means any object.The only way you could restrict the type would be using protocols:
Therefore, in this way, you point to any object which adopts the
myProtocolprotocol.