Possible Duplicate:
Class methods which create new instances
I am wondering how to emulate the instantiation of classes like NSString, NSArray and such like this: [NSArray arrayWithObject:object]… in hope of eliminating inits and allocs.
I may not be familiar with what that actually does. According the the Documentation, [NSSArray array] creates and returns an empty array. What does that really mean, any allocations?
I want to be able to have a custom NSObject class and do: [CustomObj customObjWithData:data]
Thanks!
First write a corresponding custom
init...method:Then add a custom factory method that calls
allocand your custominit...method:If compiling with ARC, omit the
autoreleasecall.