zoukankan      html  css  js  c++  java
  • 数据归档

    保存数据,编码(数据模型里面使用)

    -(void)encodeWithCoder:(NSCoder *)aCoder

    {

        [aCoder encodeObject:_name forKey:@"name"];

        [aCoder encodeObject:_phoneNo forKey:@"phoneNo"];

    }

    读取数据,解码(数据模型里面使用)

    -(instancetype)initWithCoder:(NSCoder *)aDecoder

    {

        if (self = [super init]) {

            _name = [aDecoder decodeObjectForKey:@"name"];

            _phoneNo = [aDecoder decodeObjectForKey:@"phoneNo"];

        }

        return self;

    }

    保存数据到文档目录里面的plist文件

        [NSKeyedArchiver archiveRootObject:self.contractArray toFile:self.path];

    读取数据从文档目录里面的plist文件

     _contractArray = [NSKeyedUnarchiver unarchiveObjectWithFile:self.path];

  • 相关阅读:
    HTML
    python io
    python 线程进程
    python socket
    python 面向对象2
    python 面向对象
    python hashlib模块
    python configparser模块
    python logging模块
    数组去重方法汇总
  • 原文地址:https://www.cnblogs.com/bluceZ/p/4629367.html
Copyright © 2011-2022 走看看