如何从核心 iOS 代码引用 WatchKit 扩展中的 Swift 类? [英] How can I reference a Swift class in my WatchKit extension from the core iOS code?

查看:20
本文介绍了如何从核心 iOS 代码引用 WatchKit 扩展中的 Swift 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的 iOS 应用程序在每次从服务器更新数据时向 WatchKit 扩展发送一组数据.

I am trying to make my iOS application send the WatchKit Extension a set of data each time that data is updated from the server.

这是我的 iOS 应用程序中的代码的样子(名称已更改)

This is what the code in my iOS app looks like (names changed)

[WatchKitDataModel loadDataFromSource: currentData]

但是,iOS 应用程序无法识别 WatchKitDataModel.

However, the iOS application does not recognize the WatchKitDataModel.

错误是使用了未声明的修饰符."

The error is "use of undeclared modifier."

请帮助我让我的应用相互通信!

Please help me make my apps talk to one another!

推荐答案

确保将您的违规类添加到文档"面板中的 App 目标和 WatchKit 目标

Ensure that your offending class is added to both the App target and the WatchKit target in the Document panel

图中是一个TodayExtension,但原理是一样的.

The picture shows a TodayExtension but the principle is the same.

这篇关于如何从核心 iOS 代码引用 WatchKit 扩展中的 Swift 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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