在 xcode 项目中的目标之间共享数据 [英] Share data between targets in xcode project

查看:55
本文介绍了在 xcode 项目中的目标之间共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目有两个不同的目标(同一个应用程序的免费和付费版本),我有一个 list,其中包含我保存到 NSUserDefaults 的项目.我的问题是,有没有办法在两个版本的应用程序之间共享这个列表,而不使用 KeyChain 或类似的东西?

I have a project with two different targets (a free and a paid version of the same app) and I have a list with items that I save to NSUserDefaults. My question is, is there any way to share this list between the two version of the app, without using KeyChain or something similar ?

推荐答案

您可以使用 App Group 并在其中保存项目.项目 -> 能力 -> 应用组

Your can use App Group and save items in it. Project -> Capabilities -> App Groups

  1. 在目标中添加应用组

  1. Add App Group in your targets

使用 NSUserDefaults

例如:

NSUserDefaults *myDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"com.group.identifier"];

这篇关于在 xcode 项目中的目标之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆