Итак, я делаю это приложение для Apple Watch, и в моем приложении для часов у меня есть кнопка. При касании кнопки происходит следующее:
[WKInterfaceController openParentApplication:[NSDictionary dictionary] reply:^(NSDictionary *replyInfo, NSError *error) {
if(error) {
NSLog(@"%@",error);
}
}];
И в моем файле App Delegate я делаю это:
-(void) application:(UIApplication *)application handleWatchKitExtensionRequest:(NSDictionary *)userInfo reply:(void (^)(NSDictionary *))reply {
//Code that is not importent and is confidential
reply([NSDictionary dictionary]);
}
Тем не менее, я получаю эту ошибку, когда нажимаю кнопку:
Домен ошибки = com.apple.watchkit.errors Code = 2 «UIApplicationDelegate в приложении для iPhone никогда не вызывал ответ () в -[приложение UIApplicationDelegate: handleWatchKitExtensionRequest: ответ:]» UserInfo = 0x7fd2b9c35ae0 {NSLocalizedDescription = UIApplicationDelegate в приложении для iPhone никогда вызывается response() в -[UIApplicationDelegate application:handleWatchKitExtensionRequest:reply:]}
Я звоню reply()
, как показано выше, но он этого не видит! Кроме того, он игнорирует другой код, который у меня есть!
Кто-нибудь может объяснить, почему это происходит?
Because this method is likely to be called while your app is in the background, call the beginBackgroundTaskWithName:expirationHandler: method at the start of your implementation and the endBackgroundTask: method after you have processed the reply and executed the reply block. Starting a background task ensures that your app is not suspended before it has a chance to send its reply.
Так что, возможно, попробуйте. - person Louis Tur   schedule 24.03.2015