我收到了一些崩溃报告,我唯一能看到的是它们都是iPhone 5.我无法在iPhone 5s或6上重现崩溃,所以我认为它是64 / 32位问题。但是,代码在运行iOS 7的iPhone 4上运行良好。
崩溃发生在最后一行:
IMP imp = [self.delegate methodForSelector:aSelector];
id (*func)(id, SEL, id) = (void *)imp;
func(self.delegate, aSelector, self);
说实话,我不理解这三行代码。我发现他们在使用may cause a leak because its selector is unknown
时克服了编译器警告[self.delegate performSelector:aSelector withObject:self];
当我使用performSelector
推送更新时,它不会崩溃。
我需要传递self
的参数和选择器,这就是为什么我使用IMP
并添加self
作为第三个参数,这是我应该如何阅读它。
实际的崩溃日志并没有发现太多:
Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x00000100 Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x30ca26b8 objc_retain + 7
1 Timeout 0x0009e2a1 __50-[BaseOperation finishedSuccessfullyWithSelector:]_block_invoke_2 (BaseOperation.m:47)
2 libdispatch.dylib 0x311e87bb
_dispatch_call_block_and_release + 10
3 libdispatch.dylib 0x311efe8b _dispatch_after_timer_callback + 66
4 libdispatch.dylib 0x311e87a7 _dispatch_client_callout + 22
5 libdispatch.dylib 0x311f9253 _dispatch_source_latch_and_call + 626
6 libdispatch.dylib 0x311ea2ed _dispatch_source_invoke + 212
7 libdispatch.dylib 0x311ebe1f _dispatch_main_queue_callback_4CF + 330
8 CoreFoundation 0x234a39d1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
9 CoreFoundation 0x234a20d1 __CFRunLoopRun + 1512
10 CoreFoundation 0x233f0211 CFRunLoopRunSpecific + 476
11 CoreFoundation 0x233f0023 CFRunLoopRunInMode + 106
12 GraphicsServices 0x2a7e90a9 GSEventRunModal + 136
13 UIKit 0x269fc1d1 UIApplicationMain + 1440
14 Timeout 0x000a265b main (main.m:14)
有没有人可以对此有所了解?
由于
编辑---- 我现在也看到iPad 3(iOS 8.1.2)上的崩溃和iPhone 5(iOS 8.1)。然而,我仍然无法自己复制它,我还尝试了iPod(iOS 8.1)和iPad迷你视网膜(iOS 8.1.3)。这真是让我烦恼(双关语)。编辑2 ----
我已添加一些Crashlytics日志以记录self.delegate
self
imp
& func
他们似乎都很好!那么为什么下一行会崩溃?
0 | 00:01:33:665 | $ __50-[BaseOperation finishedSuccessfullyWithSelector:]_block_invoke_2 : connectComplete:
1 | 00:01:33:665 | $ delegate: <BaseMenuViewController: 0x17e5e780>
2 | 00:01:33:666 | $ self: <ConnectOperation_Virgin: 0x1902a490>{name = '(null)'}
3 | 00:01:33:667 | $ imp: 0xaa345
4 | 00:01:33:667 | $ func: 0xaa345