简体   繁体   English

CloudKit 和键值存储的区别

[英]Difference between CloudKit and Key-Value Storage

What is the difference between iCloud's "Key-value storage" and CloudKit? iCloud 的“键值存储”和 CloudKit 有什么区别?

An example scenario would be: if one were to sync a sizable array containing dictionaries, arrays, and other objects.一个示例场景是:如果要同步一个包含字典、数组和其他对象的相当大的数组。 Would the developer want to use CloudKit or Key-value storage?开发者想要使用 CloudKit 还是 Key-value 存储?

CloudKit is for syncing real data records as well as assets (files). CloudKit 用于同步真实数据记录以及资产(文件)。

iCloud's key-value storage is essential NSUserDefaults but synced across devices. iCloud 的键值存储是必不可少的NSUserDefaults但可以跨设备同步。

So think of it that way.所以这样想吧。 If it's a simple value you might store in NSUserDefaults , use key-value storage.如果它是您可能存储在NSUserDefaults的简单值,请使用键值存储。 If it's actual data you might store in a plist, database, file, or core-data, use CloudKit.如果它是您可能存储在 plist、数据库、文件或核心数据中的实际数据,请使用 CloudKit。

I just thought it might be helpful to mention that according to the iCloud Design Guide :我只是认为根据iCloud 设计指南提到这一点可能会有所帮助:

Apps may store only 1 MB of data in their key-value storage应用程序在其键值存储中只能存储 1 MB 的数据

So that may be something that one would want to take into account in deciding between CloudKit and iCloud Key-Value Storage.所以这可能是人们在决定 CloudKit 和 iCloud 键值存储之间需要考虑的事情。

In my case, for the app I'm currently working on this limitation is totally fine.就我而言,对于我目前正在处理此限制的应用程序来说完全没问题。 However, I would imagine that in a larger project the 1 MB limit might not be sufficient.但是,我认为在更大的项目中,1 MB 的限制可能是不够的。 Helps to know that up front when making the decision!有助于在做出决定时预先了解这一点!

Hope this helps!希望这可以帮助!

Worth noting that there are more limitations to the iCloud Key-Value storage than the 1MB limit per user (mentioned in other answers before).值得注意的是, iCloud Key-Value storage的限制比每位用户 1MB 的限制要多(之前在其他答案中提到过)。

There are some limits to the size of data you can store:您可以存储的数据大小有一些限制:

  • A maximum, overall key-value store size of 1 MB (per user)最大的整体键值存储大小为 1 MB(每个用户)
  • One key-value pair can't be larger than 1 MB一个键值对不能大于 1 MB
  • You can't store more than 1024 key-value pairs不能存储超过 1024 个键值对
  • A key can't be larger than 64 bytes using UTF-8 encoding使用 UTF-8 编码的密钥不能大于 64 个字节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM