I was reading about initializing the archived objects from a XIB file and found that
- (id)initWithCoder:(NSCoder *)aDecoder
is a way of doing it. But I am not able to get a hang around this. Can someone show me an simple example of how to do this?
Thanks a ton
The
NSCoderclass is used toarchive/unarchive(marshal/unmarshal, serialize/deserialize) ofobjects.This is a method to write objects on streams (like files, sockets) and being able to retrieve them later or in a different place.
I would suggest you to read Archiving
You also need to define the following method as follows:
And in the initWithCoder method initialize as follows:
You can initialize the object standard way i.e
Example taken from this answer