Suppose I have a function like this:
- (NSSet *) someFunction {
//code...
return [[[NSSet alloc] initWithObjets:obj1, obj2, nil] autorelease];
}
When I call this function, do I need to do retain/release the return value? I'm assuming I do.
However, what if I don't do autorelease, so someFunction now looks like this:
- (NSSet *) someFunction {
//code...
return [[NSSet alloc] initWithObjets:obj1, obj2, nil];
}
In this case, I'm assuming I need to release but not retain the return value.
My question is, what is the suggested/best practice for these kinds of situations? Is one or the other version of someFunction recommended? Thanks.