zl程序教程

您现在的位置是:首页 >  云平台

当前栏目

SwiftUI CloudKit 入门之 22 识别应用程序的容器

识别容器入门应用程序 SwiftUI 22 CloudKit
2023-09-11 14:18:47 时间

识别应用程序的容器

使用Xcode的Project导航器查找活动CloudKit容器的标识符。


概述

应用程序的Xcode项目管理该应用程序可以使用哪些CloudKit容器。当您编写需要为应用程序使用的所有容器提供容器标识符的代码时,请参考Xcode中的活动容器列表。


确定您的应用使用的容器

在应用程序的Xcode项目中,在项目导航器中选择“功能”>“ iCloud”。
image.png

确定应用程序使用的容器后,您可以CKContainer在应用程序中创建实例并与CloudKit数据进行交互。

// These constants correspond to the containers selected above.
let defaultContainer = CKContainer.default()
let documents = CKContainer(identifier: "iCloud.com.example.myexampleapp.documents")
let settings = CKContainer(identifier: "iCloud.com.example.myexampleapp.settings")

技术交流

QQ:3365059189
SwiftUI技术交流QQ群:518696470