I am reading up about Encoding and Decoding and I noticed that sometimes people miss the retain off the end, I have also noticed that retain is sometimes used on some varables but not others. Can I ask ...
(1) What is the purpose of this retain and why is it sometimes not needed?
(2) Does the use of the retain imply that I need to match it with a release, and if so where?
- (id) initWithCoder: (NSCoder *) decoder {
name = [[decoder decodeObjectForKey: @"CardName"] retain];
email = [[decoder decodeObjectForKey: @"CardEmail"] retain];
}
or
- (id) initWithCoder: (NSCoder *) decoder {
name = [decoder decodeObjectForKey: @"CardName"];
email = [decoder decodeObjectForKey: @"CardEmail"];
}
gary