1

Let's say I have a protocol, call it Protocol A. I want every class implementing A to have a method that has a return value of itself.

For example, class Implementor should have a method called "GetAnother" with a return value of Implementor.

Is this possible to force a class to do with Protocols? Because as far as I can see, you have to create methods with specific return values.

I don't want to return an id because I want people to be able to depend on the return value being a certain class.

Thanks!

Edan Maor
  • 9,772
  • 17
  • 62
  • 92
  • as far as i know there's no straigthforward way of doing that... but i'd like to hear some thougts on this – jere Nov 01 '12 at 13:47
  • Does this help? http://stackoverflow.com/questions/3582504/return-type-of-self-class – Vinnie Nov 01 '12 at 13:50

1 Answers1

0

You're looking for Template classes in Objective-C, but it doesn't exist. See here for instance.

Community
  • 1
  • 1
Bgi
  • 2,513
  • 13
  • 12