简体   繁体   English

“ iPhone应用程序中的UIApplicationDelegate从未调用reply()”错误突然

[英]'The UIApplicationDelegate in the iPhone App never called reply()' error all of a sudden

I recently reverted back to a previous version of my app through my Time Capsule backup, and everything is working as it should be with the exception of one thing. 我最近通过Time Capsule备份恢复了我的应用程序的先前版本,除了一件事之外,一切都应该正常进行。 When I try to use the watch extension for my app, it never receives a reply from the parent application. 当我尝试为我的应用程序使用watch扩展名时,它永远不会收到父应用程序的回复。 I haven't changed any code, but it doesn't work no matter what. 我没有更改任何代码,但是无论如何它都不起作用。 Even if I just send an empty request and a simple string back, I get the same error: 即使我只是发送一个空请求和一个简单的字符串,我也会收到相同的错误:

The UIApplicationDelegate in the iPhone App never called reply() iPhone应用程序中的UIApplicationDelegate从未调用Reply()

This is (the simplified version of) my code: 这是我的代码(的简化版本):

override func awakeWithContext(context: AnyObject?) {
    super.awakeWithContext(context)

    WKInterfaceController.openParentApplication(["test": "test"]) { userInfo, error in
        println("User Info: \(userInfo)")
        println("Error: \(error)")
    }        
}

Delegate: 代表:

func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: (([NSObject : AnyObject]!) -> Void)!) {
    let favouritesArrayDefaults = NSUserDefaults.standardUserDefaults().arrayForKey("favourites")!

    if let pfqueryRequest: AnyObject = (userInfo as? [String: AnyObject])?["parkName"] {
    } else {
        let taskID = beginBackgroundUpdateTask()

        reply(["Success": "Success"])

        endBackgroundUpdateTask(taskID)
    }
}

Anyone have any ideas? 有人有想法么?

You are supposed to call the watch's reply function immediately. 您应该立即调用手表的回复功能。 You can't wait until an async function completes. 您不能等到异步功能完成。 By then the watch has given up and decided the phone isn't going to reply. 届时,手表已放弃,并决定手机将不会回复。 I can't find the statement to that effect in Apple's docs any more, but I do remember reading it. 在苹果的文档中,我再也找不到这种效果的声明了,但是我确实记得读过它。

Your code does not call the replyBlock in the first if block (before the else). 您的代码不会在第一个if块中调用elseBlock(在else之前)。 Might that be the code path that you see the error log for? 可能是您看到错误日志的代码路径吗?

Figured it out! 弄清楚了! The line: 该行:

let favouritesArrayDefaults = NSUserDefaults.standardUserDefaults().arrayForKey("favourites")!

Would crash if the array was empty. 如果数组为空将崩溃。 This was the first time I had tried the watch app with an empty array in the main app so that was why it had never occurred before. 这是我第一次在主应用程序中尝试使用带有空数组的watch应用程序,因此这是以前从未发生过的原因。

暂无
暂无

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

相关问题 “ iPhone应用程序中的UIApplicationDelegate从未在-[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]中调用reply()” - “The UIApplicationDelegate in the iPhone App never called reply() in -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]” “ iPhone应用程序中的UIApplicationDelegate从未调用reply()”-Xamarin - “The UIApplicationDelegate in the iPhone App never called reply() ” - Xamarin iPhone应用程序中的UIApplicationDelegate从未调用过回复 - The UIApplicationDelegate in the iPhone App never called reply 错误Domain = com.apple.watchkit.errors代码= 2“ iPhone应用程序中的UIApplicationDelegate从未调用Reply()nsmutablearray - Error Domain=com.apple.watchkit.errors Code=2 "The UIApplicationDelegate in the iPhone App never called reply() nsmutablearray 应用收到通知,但在第一次会话中未调用UIApplicationDelegate方法 - App receives notification but UIApplicationDelegate method isn't called in first session 不调用UIApplicationDelegate方法 - UIApplicationDelegate methods not being called App突然抛出NSInvalidArgumentException - App is all of the sudden throwing an NSInvalidArgumentException NSXMLParser 错误代码突然=5 - NSXMLParser error code=5 all of a sudden iPhone应用程序永远不会在设备上运行 - iphone app never runs on device 从未在应用图标触摸启动中调用didReceiveLocalNotification - didReceiveLocalNotification is never called in app icon touched launch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM