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
ios NSKeyedArchiver 保存对象与对象数组的更多相关文章
- 如果一个Object对象可能是数组那么如何对其进行迭代
需求:一个方法传入的参数是Object类型(假设对象为“items”,使用Object类型也是为了使用多态而增加方法复用性),但已知这个Object对象可能是基本类型数组,也可能是对象数组,如何将这个 ...
- JS 字符串对象 数组对象 函数对象 函数作用域
一.内置对象 object对象:ECMAScript 中的所有对象都由这个对象继承而来:Object 对象中的所有属性和方法都会出现在其他对象中 ToString() : 返回对象的原始字符串表示.V ...
- python 全栈开发,Day51(常用内置对象,函数,伪数组 arguments,关于DOM的事件操作,DOM介绍)
昨日内容回顾 1.三种引入方式 1.行内js <div onclick = 'add(3,4)'></div> //声明一个函数 function add(a,b){ } 2. ...
- Android SharedPreferences保存和读取对象
SharedPreferences保存和读取对象 1.首先要序列化对象(以下是序列化实体类的样例,不方便贴出实体类全部的代码) public class LoginResult extends Bas ...
- 前端JavaScript(2) --常用内置对象,函数,伪数组 arguments,关于DOM的事件操作,DOM介绍
昨日内容回顾 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ...
- ES6复制拷贝数组,对象,json数组
扩展运算符的应用spread打散数组[...] (1)复制数组 数组是复合的数据类型,直接复制的话,只是复制了指向底层数据结构的指针,而不是克隆一个全新的数组. const a1 = [1, 2]; ...
- 简述JavaScript对象、数组对象与类数组对象
问题引出 在上图给出的文档中,用JavaScript获取那个a标签,要用什么办法呢?相信第一反应一定是使用document.getElementsByTagName('a')[0]来获取.同样的,在使 ...
- yii2得到的数据对象转化成数组
yii2得到的数据对象转化成数组需要用到asArray().1.Customer::find(['id' => $id])->asArray()->one();2.$model = ...
- struts2:遍历自定义字符串数组,遍历Action实例所引用对象中的数组
在struts2:OGNL表达式,遍历List.Map集合:投影的使用一文中已经讲述了OGNL遍历List.Map集合等功能. 本文简单写一个遍历数组的示范程序. 1. 遍历自定义字符串数组 < ...
随机推荐
- mac 常用的开发工具
http://www.oschina.net/news/53946/mac-dev-tools 要清楚的认识到,我们寻找的不是开始按钮,而是程序入口,任何一个操作系统,用户要做的事情并不是找到开始菜单 ...
- Cracking the coding interview--Q1.6
原文: Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a m ...
- 注意:rsyslog 源码安装 会出现日志重复发的情况,需要rpm包安装
cd /etc/yum.repos.d;wget http://rpms.adiscon.com/v8-stable/rsyslog.repo uat-web02:/etc/yum.repos.d# ...
- Linux中.a,.la,.o,.so文件的意义和编程实现
Linux中.a,.la,.o,.so文件的意义和编程实现 Linux下文件的类型是不依赖于其后缀名的,但一般来讲: .o,是目标文件,相当于windows中的.obj文件 ...
- SPOJ694 -- DISUBSTR 后缀树组求不相同的子串的个数
DISUBSTR - Distinct Substrings Given a string, we need to find the total number of its distinct su ...
- BZOJ1176---[Balkan2007]Mokia (CDQ分治 + 树状数组)
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1176 CDQ第一题,warush了好久.. CDQ分治推荐论文: 1 <从<C ...
- [LeetCode] Maximum Gap 解题思路
Given an unsorted array, find the maximum difference between the successive elements in its sorted f ...
- Java 8 默认方法和多继承深入解析
以前经常谈论的Java对比c++的一个优势是Java中没有多继承的问题. 因为Java中子类只能继承(extends)单个父类, 尽管可以实现(implements)多个接口,但是接口中只有抽象方法, ...
- iOS UITableView 修改滚动条颜色 默认选中第一条
//隐藏 self.tableView.showsVerticalScrollIndicator = NO; //修改颜色 self.tableView.indicatorStyle=UIScroll ...
- 转义字符和ASCII
一.字符(char) 数字(int) 屏幕显示 '\n' 10 换行 '\0' ...