My Questing is
-(ABC*)createInstance
{
Static ABC *obj = [[alloc ABC] init];
if(obj == nil)
{
obj = [[alloc ABC] init];
}
return obj
}
can we write in objective c
[[ABC createInstance] release]
My Questing is
-(ABC*)createInstance
{
Static ABC *obj = [[alloc ABC] init];
if(obj == nil)
{
obj = [[alloc ABC] init];
}
return obj
}
can we write in objective c
[[ABC createInstance] release]
Yes, users could release your instance if you haven't overridden retain/release. Take a look at common singleton patterns for better approaches.
Notes:
[ClassName alloc], not [alloc ClassName] createInstance a class method use + (ABC*)createInstance;static, not Staticobj to nilself instead of ABC if subclassing is a concern: [self alloc]sharedInstance