码迷,mamicode.com
首页 > 其他好文 > 详细

归档和解档---秀清

时间:2015-05-24 17:09:42      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

//
//  AccountTool.h
//
//  Created by Joe Zhang on 15/5/23.
//  Copyright (c) 2015年 张秀清. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Account.h"

@interface AccountTool : NSObject
//存储账号
+(void)save:(Account *)account;
//读取账号
+(Account *)account;

@end

//

//  AccountTool.m

//

//  Created by Joe Zhang on 15/5/23.

//  Copyright (c) 2015年 张秀清. All rights reserved.

//

 

#import "AccountTool.h"

 

#define AccountFilePath [NSHomeDirectory() stringByAppendingPathComponent:@"account.data"]

 

@implementation AccountTool

 

+(void)save:(Account *)account{

    

    //归档

    [NSKeyedArchiver archiveRootObject:account toFile:AccountFilePath];

}

 

+(Account *)account{

    //解档

 

    Account * account = [NSKeyedUnarchiver unarchiveObjectWithFile:AccountFilePath];

    

//    NSDate *now = [NSDate date];

//    if ([now compare:account.expires_time]!= NSOrderedAscending) {

//        

//        return  nil;

//    }

    

    return account;

}

 

@end

 

 

归档和解档---秀清

标签:

原文地址:http://www.cnblogs.com/sixindev/p/4525904.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!