Nested factory methods in Objective-C
- by StephenT
What's the best way to handle memory management with nested factory methods, such as in the following example?
@implementation MyClass
+ (MyClass *) SpecialCase1
{
return [MyClass myClassWithArg:1];
}
+ (MyClass *) SpecialCase2
{
return [MyClass myClassWithArg:2];
}
+ (MyClass *) myClassWithArg:(int)arg
{
MyClass *instance =…