iCloud + UIDocument

来源:互联网 发布:云转码软件 编辑:程序博客网 时间:2024/05/16 18:34

iCloud很显然,你可以将一些文件同步到iCloud之上,可以有几种同步数据类型,支持比较好的就是UIDocument

iCloud的三种存储方式 Key-Value, Documents, Core Data都是在之前已有的框架上进行扩展的高级接口。

iCloud + Key-Value对应的基础是NSUserDefaults。 

iCloud + Documents对应的基础是使用文档进行数据存储(NSFileManager,NSFileCoordinator,NSFileWrapper,NSCoding等一系列持久化数据存储到文件的问题).

iCloud + Core Data的对应基础就是Core Data。



1.NSFileManager

iOS文件系统

https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/index.html

一些栗子

http://liwpk.blog.163.com/blog/static/36326170201158229415/

2.UIDocument

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIDocument_Class/index.html

它帮你处理好write,read等基本操作,使得你从一些反复底层解脱出来

http://blog.csdn.net/samrtian/article/details/12883815

3.NSFileCoordinator

https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSFileCoordinator_class/index.html

4.NSFileWrapper

5.NSCoding

6.NSFileVersion

最后,多个终端(touch,pad或者iphone)同时处理文件时候,一定会产生冲突,这时候就需要使用NSFileVersion解决冲突问题

https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSFileVersion_Class/index.html


app文件目录结构



http://www.raywenderlich.com/12779/icloud-and-uidocument-beyond-the-basics-part-1

http://www.raywenderlich.com/12794/icloud-and-uidocument-beyond-the-basics-part-2

http://www.raywenderlich.com/12816/icloud-and-uidocument-beyond-the-basics-part-3

http://www.raywenderlich.com/12837/icloud-and-uidocument-beyond-the-basics-part-4

0 0
原创粉丝点击