YapDatabase可以直接储存(序列化)对象,包括自定义对象,但是你要让对象实现NSCoding协议。
当然,也可以自己向YapDatabase提供序列化/反序列化对象。自己去实现这一过程。
- (id)initWithPath:(NSString *)path
serializer:(YapDatabaseSerializer)serializer
deserializer:(YapDatabaseDeserializer)deserializer;
/**
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;