美文网首页
文件存储类型总结

文件存储类型总结

作者: 小千 | 来源:发表于2020-04-01 19:02 被阅读0次

1、Property Lists

属性列表,扩展名为plist。

  • Property list有三种存储方式:XML, binary format, “old-style” ASCII format inherited from OpenStep。old-style format的序列化API是只读的。

A property list can be stored in one of three different ways: in an XML representation, in a binary format, or in an “old-style” ASCII format inherited from OpenStep. You can serialize property lists in the XML and binary formats. The serialization API with the old-style format is read-only.

  • 数据大小限制(几百kb内)

For situations where you need to store small amounts of persistent data—say less than a few hundred kilobytes—property lists offer a uniform and convenient means of organizing, storing, and accessing the data.
In some situations, the property-list architecture may prove insufficient. If you need a way to store large, complex graphs of objects, objects not supported by the property-list architecture, or objects whose mutability settings must be retained, use archiving.

  • 如果我们的对象全由NSDictionary, NSArray, NSString, NSDate, NSData, 或NSNumber类派生,我们可以创建property list。

  • XML property list 比 binary 格式的可移植性好,可以手动编辑,但是binary property lists 兼容性好,需要的存储空间少,读写速度要优于XML property lists。通常来说,如果你的property list相对较小,XML property lists的优点会战胜它相对binary property lists的I/O速度,难兼容的缺点。

  • 如果你有大量数据,binary property lists, keyed archives,或自定义数据格式会是更好的解决方案。

2、NSUserDefaults

  • NSUserDefaults,提供了与默认系统交互的程序接口。

  • 默认系统允许应用去自定义它的行为来符合用户的偏好。所以它主要是用来存储配置信息。

  • 支持的数据类型有:floats,doubles,integers,Booleans,URLs,NSData,NSString,NSNumber,NSDate,NSArray和NSDictionary。如果还想存储其他类型的对象,需要使用NSData对它们进行归档。

  • 事实上,NSUserDefaults就是把数据保存在property list中

3、Archive

归档

Archives provide a means to convert objects and values into an architecture-independent stream of bytes that preserves the identity of and the relationships between the objects and values.

  • 如果对象是NSString、NSDictionary、NSArray、NSData、NSNumber等类型,可以直接用NSKeyedArchiver进行归档和恢复。

  • 不是所有的对象都可以直接用这种方法进行归档,只有遵守了NSCoding协议的对象才可以。

3、DB

数据库可以提供对数据更加高级的操作,这是其他方式不能提供的。当涉及到建模,查询,遍历,持久化复杂的对象图,就可以采用数据库来实现数据持久化。

  • SQLite
  • Core Data
  • FMDB

相关文章

  • 文件存储类型总结

    1、Property Lists 属性列表,扩展名为plist。 Property list有三种存储方式:XML...

  • Python中List的存储和读取

    List的存储,存储为txt类型 List的读取,读取txt类型文件 完成!

  • 一.C#中值类型与引用类型

    总结:值类型直接存储其值,引用类型存储对值的引用,值类型存在堆栈上,引用类型存储在托管堆上,值类型转为引用类型叫做...

  • Android数据持久化之文件存储

    参考:Android 中的文件操作Android文件存储总结存储选项-AndroidDevelopers 一. 文...

  • ftp(一)安装部署

    相关知识 1.NAS:共享文件,网络加文件存储。2.SAN:共享设备,存储加网络。 文件共享类型。 1.ftp:文...

  • Mysql 基础知识2

    数据查询流程 日志文件类型 存储引擎的存储和提取 InnoDB文件:.frm .idb .ibdata索引和数据存...

  • Android文件存储总结

    存储路径及演化 首先看这张文件从Android文件存储使用参考转载的存储结构图,里面明确了通过各种Android接...

  • 前端视频2-第一部分

    2.文件类型,xtml介绍。 xml文件规则严格 xml文件是为了存储和传递数据而用 网页文档类型介绍 一个htm...

  • 大数据学习,全面解析-分布式文件系统

    分布式文件存储系统主要被分为三种类型:分布式文件存储、块存储、对象存储。这三种存储系统都有着自己的特点和适用场景。...

  • MYSQL-InnoDB引擎

    一、MYSQL存储引擎: InnoDB存储引擎作用:规划和存取数据,类似于Linux文件系统 1、查看存储引擎类型...

网友评论

      本文标题:文件存储类型总结

      本文链接:https://www.haomeiwen.com/subject/oenmoqtx.html