ios NSKeyedArchiver 保存对象与对象数组

废话不说,直接上代码

 //
// CommunityTool.h
// SmartCommunity
//
// Created by chenhuan on 15/9/2.
// Copyright (c) 2015年 smartcommunity. All rights reserved.
// #import <Foundation/Foundation.h>
@interface CommunityTool : NSObject
+ (void)SaveComunity:(NSArray *)homepageBeans;
+ (NSMutableArray *)HomePageBean;
@end
 //
// CommunityTool.m
// SmartCommunity
//
// Created by chenhuan on 15/9/2.
// Copyright (c) 2015年 smartcommunity. All rights reserved.
// #import "CommunityTool.h" #define SChomepagePath [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"homepage.archive"] @implementation CommunityTool
+ (void)SaveComunity:(NSArray *)homepageBeans{
[NSKeyedArchiver archiveRootObject:homepageBeans toFile:SChomepagePath];
}
+ (NSMutableArray *)HomePageBean{
return [NSKeyedUnarchiver unarchiveObjectWithFile:SChomepagePath];
}
@end
上一篇:【转】四步完成win7 ubuntu双系统安装(硬盘,无需光驱)


下一篇:Tomcat原理 分类: 原理 2015-06-28 19:26 5人阅读 评论(0) 收藏