YapDatabase 学习笔记(三)

前端之家收集整理的这篇文章主要介绍了YapDatabase 学习笔记(三)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

YapDatabase可以直接储存(序列化)对象,包括自定义对象,但是你要让对象实现NSCoding协议。
当然,也可以自己向YapDatabase提供序列化/反序列化对象。自己去实现这一过程。

- (id)initWithPath:(NSString *)path
    serializer:(YapDatabaseSerializer)serializer
  deserializer:(YapDatabaseDeserializer)deserializer;
  • (id)initWithPath:(NSString *)path objectSerializer:(YapDatabaseSerializer)objectSerializer
    objectDeserializer:(YapDatabaseDeserializer)objectDeserializer
    MetadataSerializer:(YapDatabaseSerializer)MetadataSerializer
    MetadataDeserializer:(YapDatabaseDeserializer)MetadataDeserializer;

/**

    • The default serializer & deserializer use NSCoding (NSKeyedArchiver & NSKeyedUnarchiver).

    • Thus any objects that support the NSCoding protocol may be used.
      *

    • Many of Apple's primary data types support NSCoding out of the Box.

    • It's easy to add NSCoding support to your own custom objects.
      **/

    • (YapDatabaseSerializer)defaultSerializer;

    • (YapDatabaseDeserializer)defaultDeserializer;

    /**

    • Property lists ONLY support the following: NSData,NSString,NSArray,NSDictionary,NSDate,and NSNumber.

    • Property lists are highly optimized and are used extensively by Apple.

    • Property lists make a good fit when your existing code already uses them,

    • such as replacing NSUserDefaults with a database.
      **/

    • (YapDatabaseSerializer)propertyListSerializer;

    • (YapDatabaseDeserializer)propertyListDeserializer;

    /**

    • A FASTER serializer & deserializer than the default,if serializing ONLY a NSDate object.

    • You may want to use timestampSerializer & timestampDeserializer if your Metadata is simply an NSDate.
      **/

    • (YapDatabaseSerializer)timestampSerializer;

    • (YapDatabaseDeserializer)timestampDeserializer;

    原文链接:/note/421738.html

    猜你在找的程序笔记相关文章