1.首先将自定义对象进行保存写入本地文件

NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self.obj];

[data writeToFile:@"Path" atomically:YES];

2.在接口中实现协议<NSCoding>来支持encodedecode功能

 (void)encodeWithCoder:(NSCoder *)aCoder

{

    [aCoder encodeObject:self.obj.title forKey:@"title"];

    [aCoder encodeObject:self.obj.text forKey:@"text"];

}

 

- (id)initWithCoder:(NSCoder *)aDecoder

{

    if (self == [superinit])

    {

        self.obj.text = [[aDecoderdecodeObjectForKey:@"title"];

        self.obj.text = [aDecoderdecodeObjectForKey:@"text"];

    }

    

     return self;

}