Use the (plus) + in front of your method instead of the (minus) -
Example (assuming your class name is MyClass, and this method is defined within the implementation):
+(MyClass *)getMyClassInstanceOfType:(int) myClassTypeID
{
MyClass *retMyClass = [[MyClass alloc] init];
switch(myClassTypeID)
{
...
}
return retMyClass;
}
{
MyClass *retMyClass = [[MyClass alloc] init];
switch(myClassTypeID)
{
...
}
return retMyClass;
}
This method can be called in your code without instantiating anything like this (assuming #define kMyClassTypeFoo 1 is in the header):
MyClass *myClass = [MyClass getMyClassInstanceOfType:kMyClassTypeFoo];
Hopefully that's a time-saver for someone.
Hello,
ReplyDeleteUseful information, many thanks to the author. It is puzzling to me now, but in general, the usefulness and significance is overwhelming. Very much thanks again and best of luck!
Hire iphone Developer