views:

25

answers:

1

So far I have the following:

- (id)initWithCoder:(NSCoder*) coder
{
    self = [super initWithCoder: coder];
    if (self) {
        // Call a setup method
    }
    return self;
}

Am I supposed to put the code to load the array in here? What could should I put and where should I put it?

+1  A: 

You put myArray=[coder decodeObjectForKey:@"myArray"]; inside the if block.

If you haven't set up the encoding part of the code yet, to do that you just add a method:

- (void)encodeWithCoder:(NSCoder *)encoder {
    [encoder encodeObject:myArray forKey:@"myArray"];
}
grahamparks
That would result in `myArray` being released next time the autorelease pool is drained - you need to take ownership of it.
Georg Fritzsche