iOS笔记—归档解档

ios数据持久化的一种方式。归档解档

//
//  main.m
//  NSKeyedArchiver
//
//  Created by hhg on 15/9/10.
//  Copyright (c) 2015年 hhg. All rights reserved.
//

#import 

int main(int argc, const char * argv[]) {
    @autoreleasepool {

        NSString * homeDirectory = NSHomeDirectory();
        NSArray *array = @[@2234,@YES,@.23,@"2399",@"china"];

        // 归档
        NSString * filePath = [homeDirectory stringByAppendingPathComponent:@"array.acrchive"];
        if ([NSKeyedArchiver archiveRootObject:array toFile:filePath]) {
            NSLog(@"archiver success");
        };

        //解档
        NSArray *unArray=[NSKeyedUnarchiver unarchiveObjectWithFile:filePath];
        NSLog(@"%@",unArray);
    }
    return 0;
}

你可能感兴趣的:(iOS--OC语法与基础)