A lightweight framework for writing and reading object to/from local files. An upgrade version of JObjectCoder
###Provide
- Serialize instance of custom class into local file.
- Deserialize a local file into instance.
- Contain reference relation.(One object as a property of different object. After the serialize and deserialize those two pointer still point one object)
- Easy to use.
###Principle
- Till now, properties only suupport NSString,NSNumber and value type
- The class wants to be serialized should confirm the coder protocol
###TODO
- Including more class like dicitonary,array...
###Environment
- iOS SDK 7.0
- Xcode 5
- ARC Mode
###API
- JCoderManager
/**
* @brief encode an object
*
* @param object object
*
* @return coding key
*/
+ (NSString *)encode:(NSObject *)object;
/**
* @brief decode object from key
*
* @param key key
*
* @return object
*/
+ (NSObject *)decode:(NSString *)key;
- JEncoder
/**
* @brief serialize object into dictionary
*
* @param object object for serializing
* @param setter handle object and dictionary info
*/
+ (void)serializeObject:(NSObject *)object handler:(JEncoderHandler)handler;
- JDecoder
/**
* @brief deserialize object from NSDictionary
*
* @param dic dic info
* @param getter get dic with key
*
* @return object
*/
+ (NSObject *)objectWithDic:(NSDictionary *)dic handler:(JDecoderHandler)handler;
###Code Sample
- (void)test
{
A *a = [[A alloc] init];
a.identifier = 5;
NSString *key = [JCoderManager encode:a];
a = (A *)[JCoderManager decode:key];
NSLog(@"%d",a.identifier);
NSLog(@"%@,%@",a.b,a.b2);
}