// // 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