我遇到WCSession activateSession
的问题。
我在viewDidLoad
方法中添加了此代码,并且在activateSession
调用时崩溃了。 sendMessage也崩溃了。
if ([WCSession isSupported]) {
[WCSession defaultSession].delegate = self;
[[WCSession defaultSession] activateSession];
}
我虽然遇到了这个问题,但我调试它并在主线程上调用这些问题。
任何想法可能是什么问题?
这是崩溃日志:
线程#1:tid = 0x10aa81,0x0000000110917817 libobjc.A.dylib objc_msgSend + 23, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x408f59958d3)
frame #0: 0x0000000110917817 libobjc.A.dylib
objc_msgSend + 23
帧#1:0x000000010be8fd1c myApp +[CRWCSessionDelegateProxy performSwizzledWCSessionActivateSession:] + 62
frame #2: 0x000000010be8f869 myApp
+ [CRWCSessionDelegateProxy activateSessionForWCSession:dispatch:] + 72
帧#3:0x000000010be8ec64 myApp __72+[CRWCSessionDelegateProxy swizzleWCSessionActivateSessionWithDispatch:]_block_invoke + 37
* frame #4: 0x000000010bd6c4e4 myApp
- [FPMAppDelegate应用程序:didFinishLaunchingWithOptions:](自= 0x00007ff588d06800,_cmd ="应用程序:didFinishLaunchingWithOptions:",application = 0x00007ff588c00850,launchOptions = 0x0000000000000000)+ 5236 at FPMAppDelegate.m:188
帧#5:0x000000010e50d1f1 UIKit -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 272
frame #6: 0x000000010e50e397 UIKit
- [UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3415
帧#7:0x000000010e514cc6 UIKit -[UIApplication _runWithMainScene:transitionContext:completion:] + 1760
frame #8: 0x000000010e511e7b UIKit
- [UIApplication workspaceDidEndTransaction:] + 188
帧#9:0x0000000113203754 FrontBoardServices -[FBSSerialQueue _performNext] + 192
frame #10: 0x0000000113203ac2 FrontBoardServices
- [FBSSerialQueue _performNextFromRunLoopSource] + 45
帧#11:0x0000000110db4a31 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
frame #12: 0x0000000110daa95c CoreFoundation
__ CFRunLoopDoSources0 + 556
帧#13:0x0000000110da9e13 CoreFoundation __CFRunLoopRun + 867
frame #14: 0x0000000110da9828 CoreFoundation
CFRunLoopRunSpecific + 488
帧#15:0x000000010e5117cd UIKit -[UIApplication _run] + 402
frame #16: 0x000000010e516610 UIKit
UIApplicationMain + 171
第17帧:0x000000010bcdc8cf myApp main(argc=1, argv=0x00007fff540ca3c0) + 111 at main.m:16
frame #18: 0x0000000111ab292d libdyld.dylib
开始+ 1
答案 0 :(得分:3)
我的应用程序中有Crittercism框架。一旦我在我的app delegate方法中注释了这一行,一切正常。
[Crittercism enableWithAppID:CRITTERCISM_APP_ID];
如果您在应用中使用Cirttercism,请务必在Crittercism之前写下此行[[WCSession defaultSession] activateSession]
。
似乎他们有2.0支持,这就是冲突的原因。
答案 1 :(得分:1)
您的代码必须在
之前调用[Crittercism enableWithAppID:].