Consider the following code
[coder encodeObject: properties forKey:@"properties"];
Are there any restrictions on what kind of object is passed as an argument to encodeObject? Can it be an object from a custom class?
Consider the following code
[coder encodeObject: properties forKey:@"properties"];
Are there any restrictions on what kind of object is passed as an argument to encodeObject? Can it be an object from a custom class?
You can encode any object, as long as it implements the NSCoding
protocol (many 'default' classes - such as NSString
, NSArray
, NSDictionary
, NSData
, etc. - already implement this protocol, and you can encode them without problem). If you want to encode an array or dictionary of custom objects, those objects will have to implement the protocol as well.
You can read more about this in the Archives and Serializations Programming Guide and the NSCoding Protocol Reference...