ios - Watchkit 扩展测试类 - 访问错误问题

标签 ios objective-c unit-testing watchkit

我按照本 link 中“如何对我的 WatchKit 扩展进行单元测试?”部分中提到的步骤为我的 Watchkit 扩展设置了一个测试目标。 .

然后我从扩展中导入了一个 Controller 类到我的测试类中,并尝试为它创建一个对象。这会引发 EXC_BAD_ACCESS 错误。

导入语句:
#import "NotificationController.h"

创建对象:
NotificationController *controller = [[NotificationController alloc] init];

我导入的 Controller 类是WKUserNotificationInterfaceController 的子类。谁能告诉我我做错了什么?

谢谢!

最佳答案

Pivotal Labs 的这篇帖子说他们遇到了类似的问题。 http://pivotallabs.com/watchkit-test-tools-pivotalcorekit/

这听起来像直接使用 WatchKit 类(就像你一样,即使使用子类)也行不通。也许尝试将您的代码分解成一个单独的、可测试的类,并将其包含在您的 WKInterfaceController 类中。

关于ios - Watchkit 扩展测试类 - 访问错误问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28729688/

相关文章:

c# - 使用 ASMX 并模拟方法

javascript - 测试根据出生日期计算年龄的函数

ios - URL 方案项目 0 已使用

objective-c - 我如何为我的 cocoa 应用程序播放歌曲或制作启动画面?

ios - 一个View作为所有ViewController中的Status View

ios - Swift 中的方法调配

objective-c - performSelectorOnMainThread : and dispatch_async() on main queue? 有什么区别

java - 如何在 Intellij Idea 中自动移动单元测试类?

ios - 在 iOS 上使用 CoreMedia.framework 解码视频

ios - 命令 PhaseScriptExecution 因非零退出代码 flutter 而失败