Reputation: 417
I've created a protocol (LEService) that I will conform to in multiple UIViewControllers. I won't know until runtime which UIViewController service has been chosen.
Is there anyway to create an instance of an object that conforms to a protocol without saying what the object is until runtime?
Upvotes: 2
Views: 114
Reputation: 29498
Sure, you can do it like this:
id <LEService> objectName = [self returnObjectConformingToLEServiceProtocol];
id
is Objective C's generic type.
Upvotes: 3