开发者

coder encodeObject

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜