I haven't found a good answer to this question in the relevant documents, but this seems to be a rudimentary thing, so I wonder if I'm missing it somewhere.
Consider this code:
Now consider initializing that string somewhere. Often in code I've seen, the standard way is this:
My question is, why not just do this?
And then release it in the class' dealloc procedure.
Thanks
Consider this code:
Code:
@interface
class Myclass: NSObject{
SomeClass *someObject;
}
@property (nonatomic, retain) SomeClass *someObject;
@end
@implementation
@synthesize someObject;
...
@end
Now consider initializing that string somewhere. Often in code I've seen, the standard way is this:
Code:
....
SomeClass *anObject = [[SomeClass alloc] init];
self.someObject = anObject;
[anObject release];
My question is, why not just do this?
Code:
self.someObject = [[SomeClass alloc] init];
And then release it in the class' dealloc procedure.
Thanks