1. NSCoding
is a protocol and is one of the methods of saving data to files. The advantage is that you can store your objects as such if using this method.
NSData
, as mentioned in the Apple class reference is typically used for data storage and are also useful in Distributed Objects applications, where data contained in data objects can be copied or moved between applications.
2. This depends on your need to save data. Its usually enough to store all objects in a single file, and these are usually the objects that represent a entity.
3. You may refer to the following tutorial:
- List item NSCoding Tutorial for iOS
EDIT:
If you want to know about encoding images, take a look at this stackoverflow answer.
Although encoding images is not an option I would prefer. Complex objects need to be converted to primitive data as mentioned by @Anoop Vaidya in the comments.
And yes, it is possible to encode objects of classes created by you. But you have to implement NSCoding protocol in them. the following link is an apt example of a two level encoding, as you asked for:
Hope this helps!