0

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?

1 Answer 1

4

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...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.