Reputation: 26223
Do I have this right ...
// Reactor.h
@property(nonatomic, retain) NSMutableArray *reactorCore;
// Reactor.m
[self setReactorCore:[NSKeyedUnarchiver unarchiveObjectWithFile:[self dataFilePath]]];
...
-(void)dealloc {
[reactorCore release];
[super dealloc];
}
I am pretty sure I am doing this right (but just wanted to check). By my way of thinking NSKeyedUnarchiver returns an object it owns, I am then taking ownership via the @property, later I release reactorCore and all is good?
Upvotes: 1
Views: 121
Reputation: 57149
That's right. The NSKeyedUnarchiver
method—since it doesn't contain the words copy
, new
, or anything like that—will return an autoreleased object, which you need to retain (as you are doing) to keep ownership of it.
Upvotes: 3
Reputation: 7831
I believe your code is corect. When in doubt you could use Build and Analize in XCode to check for possible leaks.
Upvotes: 3