FastCoding

https://github.com/nicklockwood/FastCoding

A faster and more flexible binary file format replacement for NSCoding, Property Lists and JSON

一个用来替换 NSCoding , Property Lists 以及 JSON 方案的,快速灵活性强的二进制文件存储格式.

Purpose

FastCoder is a high-performance binary serialization format for Cocoa objects and object graphs. It is intended as a replacement for NSPropertyList, NSJSONSerializer, NSKeyedArchiver/Unarchiver and Core Data.

FastCoder 是一个高效的二进制序列化格式,用于存储 Cocoa 对象的.它被设计用来替换 NSPropertyList, NSJSONSerializer, NSKeyedArchiver/Unarchiver 以及 Core Data.

The design goals of the FastCoder library are to be fast, flexible and secure.

FastCoder 库的设计宗旨就是快,高灵活性以及安全.

FastCoder is already faster (on average) for reading than any of the built-in serialization mechanisms in Cocoa, and is faster for writing than any mechanism except for JSON (which doesn't support arbitrary object types). File size is smaller than NSKeyedArchiver, and comparable to the other methods.

FastCoder 在平均水平上读取快过任何 Cocoa 的内置的序列化方案,在写数据方面除了比 JSON (它不支持任意对象类型)慢以外,完爆其它内置的方案.而且,文件大小比 NSKeyedArchiver 小,使用方法却非常简单.

FastCoder supports more data types than either JSON or Plist coding (including NSURL, NSValue, NSSet and NSOrderedSet), and allows all supported object types to be used as the keys in a dictionary, not just strings.

FastCoder 支持的数据类型比 JSON 或者 Plist 编码(其包含了 NSURL, NSValue, NSSet 和 NSOrderedSet )更多的格式,它允许所支持格式的对象像使用键值对那样简单.

FastCoder can also serialize your custom classes automatically using property inspection. For cases where this doesn't work automatically, you can easily implement your own serialization using the FastCoding Protocol.

FastCoder 能够自动序列化你自定义的的类,通过检查你属性的方式.某些情况下无法自动工作时,你可以用 FastCoding 协议简单的实现你自己的序列化方案.

Supported OS & SDK Versions

  • Supported build target - iOS 7.0 / Mac OS 10.9 (Xcode 5.0, Apple LLVM compiler 5.0)
  • Earliest supported deployment target - iOS 5.0 / Mac OS 10.7
  • Earliest compatible deployment target - iOS 4.0 / Mac OS 10.6

NOTE: 'Supported' means that the library has been tested with this version. 'Compatible' means that the library should work on this OS version (i.e. it doesn't rely on any unavailable SDK features) but is no longer being tested for compatibility and may require tweaking or bug fixes to run correctly.

注意:'支持'意味着这个库在那个版本上测试过.'兼容'意味着这个库可以在那个OS版本上工作(i.e. 它不依赖于任何被弃用的 SDK 特性),但是,后续出现bug不再被维护.

ARC Compatibility

FastCoder is compatible with both ARC and non-ARC compile targets, however performance is better when running with ARC disabled, and it is recommended that you apply the -fno-objc-arc compiler flag to the FastCoder.m class. To do this, go to the Build Phases tab in your target settings, open the Compile Sources group, double-click FastCoder.m in the list and type -fno-objc-arc into the popover.

FastCoder 支持 ARC 以及 MRC 编译.在 MRC 下表现得好些.我建议你对 FastCoder.m 文件使用 -fno-objc-arc 编译标签.

Thread Safety

It is safe to call the FastCoder encoding and decoding method concurrently from multiple threads. It should be safe to encode the same object concurrently on multiple threads provided that you do not mutate the object while it is being encoded.

在不同的线程里并发的调用编码和解码的方法是安全的.

The chunk types supported by FastCoding are:

FCTypeNull                  an NSNull value
FCTypeAlias an alias to an previously encoded chunk in the file
FCTypeString an NSString instance
FCTypeDictionary an NSDictionary instance
FCTypeArray an NSArray instance
FCTypeSet an NSSet instance
FCTypeOrderedSet an NSOrderedSet instance
FCTypeTrue a boolean YES value
FCTypeFalse a boolean NO value
FCTypeInt32 a 32-bit integer value
FCTypeInt64 a 64-bit integer value
FCTypeFloat32 a 32-bit floating point value
FCTypeFloat64 a 64-bit floating point value
FCTypeData an NSData instance
FCTypeDate an NSDate instance
FCTypeMutableString an NSMutableString instance
FCTypeMutableDictionary an NSMutableDictionary instance
FCTypeMutableArray an NSMutableArray instance
FCTypeMutableSet an NSMutableSet instance
FCTypeMutableOrderedSet an NSMutableOrderedSet instance
FCTypeMutableData an NSMutableData instance
FCTypeClassDefinition a class definition (this is a private, internal object type used for object encoding)
FCTypeObject an arbitrary object, encoded using the FastCoding protocol
FCTypeNil a nil value (not the same as NSNull), used for nil object properties
FCTypeURL an NSURL value
FCTypePoint an NSPoint/CGPoint value
FCTypeSize an NSSize/CGSize value
FCTypeRect an NSRect/CGRect value
FCTypeRange an NSRange value
FCTypeAffineTransform a CGAffineTransform value
FCType3DTransform a CATransform3D value

附上本人的测试心得:

先打上标签

在定义一个Model,包括了字典,数组,NSDate以及NSString,还有NSInteger.

写如下代码测试

查看打印信息

完美!

再测试个高级的,新建 SonModel 继承至 Model

验证代码

打印结果

总结:

高端大气上档次,低调奢华有内涵,奔放洋气有深度,简约时尚国际范,低端粗俗甩节操,土憋矫情无下限,装模作样绿茶婊,外猛内柔女汉子,卖萌嘟嘴剪刀手,忧郁深沉无所谓,狂拽帅气吊炸天,冷艳高贵接地气,时尚亮丽小清新,可爱乡村非主流,贵族王朝杀马特,提莫团战必须死。

利用 FastCoding 将对象进行本地持久化的更多相关文章

  1. IOS开发-本地持久化存储sqlite应用

    前言 需求描述 开发测试环境 FMDB介绍 创建工程 一.前言 上一章介绍了如何开发一个IOS应用的入门案例教程:                     我的第一个IOS开发应用    本章主要将介 ...

  2. iOS应用架构谈 本地持久化方案及动态部署

    转载: iOS应用架构谈 本地持久化方案及动态部署 前言 嗯,你们要的大招.跟着这篇文章一起也发布了CTPersistance和CTJSBridge这两个库,希望大家在实际使用的时候如果遇到问题,就给 ...

  3. ssiOS应用架构谈 本地持久化方案及动态部署

    本文转载至 http://casatwy.com/iosying-yong-jia-gou-tan-ben-di-chi-jiu-hua-fang-an-ji-dong-tai-bu-shu.html ...

  4. React全家桶构建一款Web音乐App实战(六):排行榜及歌曲本地持久化

    上一节使用Redux管理歌曲相关数据,实现核心播放功能,播放功能是本项目最复杂的一个功能,涉及各个组件之间的数据交互,播放逻辑控制.这一节继续开发排行榜列表和排行榜详情,以及把播放歌曲和播放歌曲列表的 ...

  5. .NET 利用反射将对象数据添加到数据库

    .NET 利用反射将对象数据添加到数据库   一些小型的项目,在不使用其他的框架(LINQ,NHibernate,EF等等框架)的前提下,这时候一些反复的增删改查就会让我们感到极其的繁琐,厌烦,为了避 ...

  6. 利用fiddler和mock调试本地微信网页

    利用fiddler和mock调试本地微信网页 微信公众号网页是比较特殊的页面,普通页面直接打开即可访问,但对于需要请求微信相关接口的部分需要安全域名认证.这导致了使用mock数据进行开发的页面没办法走 ...

  7. Java对象在Hibernate持久化层的状态

    -临时状态:刚用new语句创建对象,还没有被持久化,并且不处于Session缓存中.处于临时状态的java对象被称为临时对象. -持久化状态:已经被持久化,并且加入到Session的缓存中.处于持久化 ...

  8. C#利用反射来判断对象是否包含某个属性的实现方法

    本文实例展示了C#利用反射来判断对象是否包含某个属性的实现方法,对于C#程序设计人员来说有一定的学习借鉴价值. 具体实现代码如下: /// <summary> /// 利用反射来判断对象是 ...

  9. tp 框架 利用反射实现对象调用方法

    <?php class Person{ public $name="xiaoming"; function say(){ echo "i am ".$th ...

随机推荐

  1. CodeIgniter典型的表单提交验证代码

    view内容: <?php echo form_open('user/reg'); ?> <h5>用户名</h5> <input type="tex ...

  2. 面试题46:求1+2+ …… +n

    题目:求1+2+…+n,要求不能使用乘除法.for.while.if.else.switch.case等关键字以及条件判断语句(A?B:C). 通常求1+2+…+n除了用公式n(n+1)/2之外,无外 ...

  3. Singleton 多线程

    单例模式 何为单例模式,在GOF的<设计模式:可复用面向对象软件的基础>中是这样说的:保证一个类只有一个实例,并提供一个访问它的全局访问点.首先,需要保证一个类只有一个实例:在类中,要构造 ...

  4. Gitlab管理用户、组、权限(二)

    一. 保护主要分支 保护某个分支,不让项目中其它的成员进行改变里面的内容,和不允许他们进行和保护的分支进行合并.当某个分支设置为保护的时候,那么拥有开者者权限或以下的权限都会受到影响. 执行步骤: 1 ...

  5. linux kernel.shmall shemax shemin解释

        Linux X86-64操作系统,Oracle 10g数据库,由8G加到16G,把kernel.shmmax参数改到17179869184(16G)后,发现只要修改sga_max_size和s ...

  6. Bootstrap--响应式图片轮播

    <div class="row"> <div class="span12"> <section id="carousel ...

  7. linux查找文件或目录命令

    inux查找文件或目录命令,前提:知道文件或者目录的具体名字,例如:sphinx.conf find 查找  find / -name dirname  查找目录 find -name filenam ...

  8. 浅谈Comparable与Comparator的区别

    平时进行自定义排序一直使用实现Comparable接口,一段时间后操作的时候居然发现有了个Comparator接口 上网差了些资料,总结笔记一下. 基本原理就是比较,底层是二叉树 比如是3,6,5,1 ...

  9. 美团客户端响应式框架EasyReact开源啦

    前言 EasyReact 是一款基于响应式编程范式的客户端开发框架,开发者可以使用此框架轻松地解决客户端的异步问题. 目前 EasyReact 已在美团和大众点评客户端的部分业务中进行了实践,并且持续 ...

  10. Bipartite Graph hdu 5313 bitset 并查集 二分图

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5313 题意: 给出n个顶点,m条边,问最多添加多少条边使之构成一个完全二分图 存储结构: bitset   ...