1
面料讓我發現,很多用戶在我的應用程序崩潰NSProxy doesNotRecognizeSelector:
crash http://i65.tinypic.com/30uqnvn.png
下列崩潰。如果我展開我看到下面的堆棧
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x18ef201c0 __exceptionPreprocess
1 libobjc.A.dylib 0x18d95855c objc_exception_throw
2 CoreFoundation 0x18ef20108 -[NSException initWithCoder:]
3 Foundation 0x18f9eb714 -[NSProxy doesNotRecognizeSelector:]
4 CoreFoundation 0x18ef24278 ___forwarding___
5 CoreFoundation 0x18ee1e59c _CF_forwarding_prep_0
6 WatchConnectivity 0x1a39caff0 __57-[WCSession onqueue_completeSwitchTask:withSessionState:]_block_invoke
7 Foundation 0x18f9e17e4 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
8 Foundation 0x18f926358 -[NSBlockOperation main]
9 Foundation 0x18f916954 -[__NSOperationInternal _start:]
10 Foundation 0x18f9e3b90 __NSOQSchedule_f
11 libdispatch.dylib 0x18dda91c0 _dispatch_client_callout
12 libdispatch.dylib 0x18ddb7444 _dispatch_queue_serial_drain
13 libdispatch.dylib 0x18ddac9a8 _dispatch_queue_invoke
14 libdispatch.dylib 0x18ddb938c _dispatch_root_queue_drain
15 libdispatch.dylib 0x18ddb90ec _dispatch_worker_thread3
16 libsystem_pthread.dylib 0x18dfb12c8 _pthread_wqthread
17 libsystem_pthread.dylib 0x18dfb0db4 start_wqthread
我假設是有什麼東西不能與WatchKit一起使用。在我的應用程序中,有一類已準備好將數據傳輸到手錶套件應用程序,但在構建階段的這一時刻,沒有提及手錶應用程序和手錶套件擴展。
在我班上的代碼是
import Foundation
import WatchConnectivity
class WatchManager: NSObject
{
func setLanguage(localization: String)
{
if #available(iOS 9.0, *) {
if WCSession.isSupported() {
let watchSession = WCSession.defaultSession()
watchSession.delegate = self
watchSession.activateSession()
if watchSession.paired && watchSession.watchAppInstalled {
watchSession.transferUserInfo(["localization": localization])
}
}
}
}
}
extension WatchManager: WCSessionDelegate
{
@available(iOS 9.3, *)
func session(session: WCSession, activationDidCompleteWithState activationState: WCSessionActivationState, error: NSError?)
{ }
@available(iOS 9.0, *)
func sessionDidBecomeInactive(session: WCSession)
{ }
@available(iOS 9.0, *)
func sessionDidDeactivate(session: WCSession)
{ }
}
有什麼建議?
嗨ccjensen,謝謝你的回覆。正如你可以在我的代碼中看到的,我有一個類WatchManager,它是NSObject的子類,並且有一個擴展,其中插入了委託的所有方法。我的項目中沒有NSProxy子類。 – Charlotte
您是否在使用任何其他可以與WCSession對象進行交互的框架(常見的是廣告和用戶跟蹤框架)? – ccjensen