我無法重現有時發生的一些錯誤。這是一個報告:一些objc_release崩潰。什麼可能是一個原因?
Exception Type: EXC_CRASH (SIGSEGV)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread: 1
Thread 0:
0 libobjc.A.dylib 0x3b4b97fa objc_release + 10
1 MyApp 0x00173610 -[AFHTTPRequestOperation error] (AFHTTPRequestOperation.m:136)
2 MyApp 0x001460ea -[RKObjectRequestOperationLogger HTTPOperationDidFinish:] (RKObjectRequestOperation.m:209)
3 CoreFoundation 0x31121e6e __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 10
4 CoreFoundation 0x31095aac _CFXNotificationPost + 1716
5 Foundation 0x31a7bec0 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
6 Foundation 0x31a807c2 -[NSNotificationCenter postNotificationName:object:] + 26
7 MyApp 0x0017e44e __34-[AFURLConnectionOperation finish]_block_invoke (AFURLConnectionOperation.m:558)
8 libdispatch.dylib 0x3b9a10c0 _dispatch_call_block_and_release + 8
9 libdispatch.dylib 0x3b9a10ac _dispatch_client_callout + 20
10 libdispatch.dylib 0x3b9a39a4 _dispatch_main_queue_callback_4CF + 264
11 CoreFoundation 0x3112a5ac __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
12 CoreFoundation 0x31128e78 __CFRunLoopRun + 1304
13 CoreFoundation 0x3109346c CFRunLoopRunSpecific + 520
14 CoreFoundation 0x3109324e CFRunLoopRunInMode + 102
15 GraphicsServices 0x35dcd2e6 GSEventRunModal + 134
16 UIKit 0x33948840 UIApplicationMain + 1132
17 MyApp 0x00014d54 main (main.m:16)
18 libdyld.dylib 0x3b9b5ab4 start + 0
Thread 1 Crashed:
0 libsystem_kernel.dylib 0x3ba59838 kevent64 + 24
1 libdispatch.dylib 0x3b9a80d0 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x3b9a261e _dispatch_mgr_thread + 34
什麼我可以從這樣的記錄瞭解?誰可以成爲罪魁禍首? AFHTTPRequestOperation.m:136沒有長相,可導致崩潰
135: - (NSError *)error {
136: if (!self.HTTPError && self.response) {
137: if (![self hasAcceptableStatusCode] || ![self hasAcceptableContentType]) {
從那裏objc_release能來
呢? objc_release是否意味着ARC試圖從內存中釋放某些東西?在什麼時候(代碼中)可以發生?
提供AFURLConnectionOperation.m的代碼:使用與塊的weakSelf碼圖案
- (void)finish {
self.state = AFOperationFinishedState;
dispatch_async(dispatch_get_main_queue(), ^{
558: [[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self];
});
}
您應該將代碼發佈到此處調用的代碼塊: __34- [AFURLConnectionOperation finish] _block_invoke(AFURLConnectionOperation.m:558) ...塊會導致保留塊中引用的對象。 – stevesliva
我已添加。 dispatch_async(dispatch_get_main_queue(),^ {[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingOperationDidFinishNotification object:self]; }); – adsurbum