All these questions!!! Just when I thought things were going to get easier.
I am trying to conceptualize what happens when an object is unarchived.
So, given, Foo.m with a string Object ivar "strVal" which implements <NSCoding>
and the documentation that
and lastly this snippet in main.m
Again, given that myFoo2 was **not** created with any of the **magic** words which would imply ownership ( and hence warrant a release method call in main), does not the **retain** call in Foo.m need a release? Or is this a simple matter that the ivar is allocated "memory" during the instantiation of instance, ( if that even makes sense) and the retain simply matches the autorelease of the returned object by the unarchiver?
Sorry if this sounds a little confusing, but my head is spinning Clarity would be appreciated.
I am trying to conceptualize what happens when an object is unarchived.
So, given, Foo.m with a string Object ivar "strVal" which implements <NSCoding>
Code:
-(id) initWithCoder: (NSCoder *) decoder
{
strVal = [ [decoder decodeObjectForKey: @"FooStrVal"]retain];
..............
and the documentation that
"decodeObjectForKey": Decodes and returns an autoreleased Objective-C object that was previously encoded with.........
and lastly this snippet in main.m
Code:
myFoo2 = [ NSKeyedUnarchiver unarchiveObjectWithFile: @"foo.arch"];
Again, given that myFoo2 was **not** created with any of the **magic** words which would imply ownership ( and hence warrant a release method call in main), does not the **retain** call in Foo.m need a release? Or is this a simple matter that the ivar is allocated "memory" during the instantiation of instance, ( if that even makes sense) and the retain simply matches the autorelease of the returned object by the unarchiver?
Sorry if this sounds a little confusing, but my head is spinning Clarity would be appreciated.