Search code examples
objective-ciosclasstemplates

Template in Objective C?


Everything is in the title :)

Is there any templates in ObjC ?

I need equivalent of c# :

public class MyClass<T> : Message

in ObjC .

Any helps will be strongly thanks :(


Solution

  • There is no such ObjC feature. While ObjC++ does exist, I strongly discourage its broad use. It has many problems from poor tool and debugger support, to poor compiler optimization, to degraded ARC performance.

    Generally templates are not required in ObjC because it is not a strongly typed language. An NSArray can hold any object, so you don't need to use a template to get the right type. Do you have a specific problem you're trying to solve? There is likely a better ObjC solution.