码迷,mamicode.com
首页 > 移动开发 > 详细

ios NSKeyedArchiver 保存对象与对象数组

时间:2015-09-02 17:20:53      阅读:333      评论:0      收藏:0      [点我收藏+]

标签:

废话不说,直接上代码

 1 //
 2 //  CommunityTool.h
 3 //  SmartCommunity
 4 //
 5 //  Created by chenhuan on 15/9/2.
 6 //  Copyright (c) 2015年 smartcommunity. All rights reserved.
 7 //
 8 
 9 #import <Foundation/Foundation.h>
10 @interface CommunityTool : NSObject
11 + (void)SaveComunity:(NSArray *)homepageBeans;
12 + (NSMutableArray *)HomePageBean;
13 @end
 1 //
 2 //  CommunityTool.m
 3 //  SmartCommunity
 4 //
 5 //  Created by chenhuan on 15/9/2.
 6 //  Copyright (c) 2015年 smartcommunity. All rights reserved.
 7 //
 8 
 9 #import "CommunityTool.h"
10 
11 #define SChomepagePath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"homepage.archive"]
12 
13 @implementation CommunityTool
14 + (void)SaveComunity:(NSArray *)homepageBeans{
15     [NSKeyedArchiver archiveRootObject:homepageBeans toFile:SChomepagePath];
16 }
17 + (NSMutableArray *)HomePageBean{
18     return [NSKeyedUnarchiver unarchiveObjectWithFile:SChomepagePath];
19 }
20 @end

 

ios NSKeyedArchiver 保存对象与对象数组

标签:

原文地址:http://www.cnblogs.com/athook/p/4778980.html

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