- (void)getFromWebwithCompletionBlock:(ResponseCallback)completionBlock
{
[/*
.... network call
*/
{
completionBlock();
}];
}
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010
0 asd 0x1001dc2cc __69-[Engine getFromWebwithCompletionBlock:]_block_invoke (Engine.m:200)
1 asd 0x10010f4d8 -[NetworkCallService sendResponseForCall:] (NetworkCallService.m:422)
2 asd 0x10010f008 -[NetworkCallService respondSuccessWithData:responseData:] (NetworkCallService.m:396)
3 asd 0x10010e778 __43-[NetworkCallService connectWithRequest:]_block_invoke_2 (NetworkCallService.m:337)
4 libdispatch.dylib 0x193f39994 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x193f39954 _dispatch_client_callout + 16
6 libdispatch.dylib 0x193f3e20c _dispatch_main_queue_callback_4CF + 1608
7 CoreFoundation 0x1820cb7f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8 CoreFoundation 0x1820c98a0 __CFRunLoopRun + 1492
9 CoreFoundation 0x181ff52d4 CFRunLoopRunSpecific + 396
10 GraphicsServices 0x18b8136fc GSEventRunModal + 168
11 UIKit 0x186bbafac UIApplicationMain + 1488
12 Mobikwik 0x1000c8fcc main (main.m:16)
13 libdyld.dylib 0x193f66a08 start + 4
据我从其他stackoverflow帖子中获取,我的completionBlock在执行之前就已经发布了。我怀疑的是,如果我将我的completionBlock作为函数的参数传递,它如何被释放?
我的函数类不是保留块吗?我目前要通过检查completionBlock是否为零来修复它,但我想知道它怎么可能是零