Not understanding this paragraph


#1

Can someone explain to me what this paragraph means. I don’t think its recursive cuz i program it manually to encode all the ivar of the object

“When an object is encoded (that is, it is the first argument in encodeObject:forKey:), that object is sent encodeWithCoder:. During the execution of its encodeWithCoder: method, it encodes its object instance variables using encodeObject:forKey: (Figure 18.1). Thus, encoding an object is a recursive process where each object encodes its “friends”, and they encode their friends, and so on.”

Excerpt From: Keur, Christian. “iOS Programming: The Big Nerd Ranch Guide (4th Edition) (Big Nerd Ranch Guides).” iBooks.


#2

Let’s say you have a house, and a house has rooms, and each room has chairs. When the house is “saved”, it is the its responsibility to save the rooms, and then it is each room’s responsibility to save the chairs. So we have something like:

House:

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

Room:

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

You’re correct that it is manual, it’s not an example of “recursive programming”. Instead, it is “characterized by recurrence or repetition”.