LeonS
LeonS

Reputation: 2714

NSCoding with custom sub Objects

I have one costum object which has a reference to another custom object. How do I encode the custom object within the one custom object in my - (void)encodeWithCoder:(NSCoder *)encoder method?

Lets say name is a string an cObj is another custom obj:

- (void)encodeWithCoder:(NSCoder *)encoder {
   [encoder encodeObject:self.name forKey:@"name"];
   [encoder encodeObject:self.cObj forKey:@"cObj"];
   }

Does this will call - (void)encodeWithCoder:(NSCoder *)encoder in my other custom object?

Thank you.

Upvotes: 1

Views: 865

Answers (1)

Roger
Roger

Reputation: 15813

cObj needs to support <NSCoding>, so yes.

Upvotes: 1

Related Questions