I am just curious if this is right, or bad practice? (i.e. using a class method to alloc/init an instance)? Also am I right in thinking that I have to release the instance in main() as its the only place I have access to the instance pointer?
// IMPLEMENTATION
+(id) newData {
DataPoint *myNewData;
myNewData = [[DataPoint alloc] init];
return myNewData;
}
.
// MAIN
DataPoint *myData;
myData = [DataPoint newData];
... stuff
[myData release];
EDIT:
Also should
myNewData = [[DataPoint alloc] init];
be (or does it not matter)
myNewData = [[self alloc] init];
EDIT_002:
Strange, when I add the autorelease I get ...
EDIT_003:
@Dave DeLong, one final question, what your saying is its perferable to:
+(id) dataPoint {
return [[[self alloc] init] autorelease];
}
rather than (where you would release in main)
+(id) new {
return [[self alloc] init];
}
cheers gary