2013-03-13 2 views
3

После более чем одного дня, читая вопросы и пытаясь применить ответы, я должен попросить дополнительную помощь.сообщение отправлено на освобожденный экземпляр

У моего приложения ios6 есть табличный вид на главном экране. После выбора ячейки, мы получаем доступ к контроллеру вида с UINavigationBar который имеет обычай кнопка «Назад», призывающий этот метод:

- (IBAction)goback:(id)sender { 
    [SVProgressHUD dismiss]; 
    if(self.presentingViewController) { 
     NSLog(@" Dismissing View Controller: %@.", self.presentingViewController); 
     [self dismissViewControllerAnimated:NO completion:nil]; 
    } 
} 

Обычно этот метод работает хорошо. Он сбой только в том случае, если мы нажимаем кнопку «Назад» очень быстро, сразу после загрузки содержимого (используя json и AFNetworking). Через 5 секунд, кнопка возврата работает нормально, но если щелкнуть его сразу после загрузки, мы получаем эту ошибку:

[28103:c07] Dismissing View Controller:  <UITabBarController: 0x7578170>. 
[28103:c07] *** -[CustomViewController respondsToSelector:]: message sent to deallocated instance 0x1257cf70 

Очевидно, что это проблема памяти. Вот почему я пытался отслеживать «Зомби». Профилируя мое приложение, я получаю этот отчет. Это показывает, что слишком много выпусков, но я не могу сказать, кто из них виновен.

Кто-нибудь знает, как интерпретировать этот отчет?

Является ли эта норма нормальной?

84 0x10291ff0 Release 3 MyApp __destroy_helper_block_ 

Просьба сообщить, нужна ли какая-либо дополнительная информация. Я благодарю вас за вашу помощь.

# Address Event Type RefCt Responsible Library Responsible Caller 
0 0x10291ff0 Malloc 1 UIKit -[UIClassSwapper initWithCoder:] 
1 0x10291ff0 Retain 2 UIKit UINibDecoderDecodeObjectForValue 
2 0x10291ff0 Retain 3 UIKit -[UIRuntimeConnection initWithCoder:] 
3 0x10291ff0 Retain 4 UIKit -[UIRuntimeConnection initWithCoder:] 
4 0x10291ff0 Retain 5 UIKit UINibDecoderDecodeObjectForValue 
5 0x10291ff0 Retain 6 UIKit UINibDecoderDecodeObjectForValue 
6 0x10291ff0 Retain 7 UIKit -[UIStoryboardScene setSceneViewController:] 
7 0x10291ff0 Retain 8 UIKit -[UINib instantiateWithOwner:options:] 
8 0x10291ff0 Release 7 UIKit -[UINibDecoder finishDecoding] 
9 0x10291ff0 Release 6 UIKit -[UIRuntimeConnection dealloc] 
10 0x10291ff0 Release 5 UIKit -[UIRuntimeConnection dealloc] 
11 0x10291ff0 Release 4 UIKit -[UINibDecoder finishDecoding] 
12 0x10291ff0 Release 3 UIKit -[UINibDecoder finishDecoding] 
13 0x10291ff0 Release 2 UIKit -[UINibDecoder finishDecoding] 
14 0x10291ff0 Retain 3 UIKit -[UIStoryboardSegue initWithIdentifier:source:destination:] 
15 0x10291ff0 Retain 4 UIKit -[UIViewController setChildModalViewController:] 
16 0x10291ff0 Retain 5 UIKit -[UIApplication _addViewControllerForLockingStatusBarTintColor:] 
17 0x10291ff0 Retain 6 UIKit -[UINib instantiateWithOwner:options:] 
18 0x10291ff0 Retain 7 UIKit +[UIProxyObject addMappingFromIdentifier:toObject:forCoder:] 
19 0x10291ff0 Retain 8 UIKit -[UINib instantiateWithOwner:options:] 
20 0x10291ff0 Retain 9 UIKit +[UIProxyObject addMappingFromIdentifier:toObject:forCoder:] 
21 0x10291ff0 Retain 10 UIKit -[UIProxyObject initWithCoder:] 
22 0x10291ff0 Retain 11 UIKit -[UIRuntimeConnection initWithCoder:] 
23 0x10291ff0 Retain 12 UIKit -[UIRuntimeConnection initWithCoder:] 
24 0x10291ff0 Retain 13 UIKit -[UIRuntimeConnection initWithCoder:] 
25 0x10291ff0 Retain 14 UIKit -[UIRuntimeConnection initWithCoder:] 
26 0x10291ff0 Retain 15 UIKit -[UIRuntimeConnection initWithCoder:] 
27 0x10291ff0 Retain 16 UIKit -[UIRuntimeConnection initWithCoder:] 
28 0x10291ff0 Retain 17 UIKit -[UIRuntimeConnection initWithCoder:] 
29 0x10291ff0 Retain 18 UIKit -[UIRuntimeConnection initWithCoder:] 
30 0x10291ff0 Retain 19 UIKit -[UIRuntimeConnection initWithCoder:] 
31 0x10291ff0 Retain 20 UIKit -[UIRuntimeConnection initWithCoder:] 
32 0x10291ff0 Retain 21 UIKit -[UIRuntimeConnection initWithCoder:] 
33 0x10291ff0 Retain 22 UIKit -[UIRuntimeConnection initWithCoder:] 
34 0x10291ff0 Retain 23 UIKit -[UIRuntimeConnection initWithCoder:] 
35 0x10291ff0 Retain 24 UIKit -[UIRuntimeConnection initWithCoder:] 
36 0x10291ff0 Retain 25 UIKit -[UIRuntimeConnection initWithCoder:] 
37 0x10291ff0 Retain 26 UIKit -[UIRuntimeConnection initWithCoder:] 
38 0x10291ff0 Retain 27 UIKit -[UIProxyObject initWithCoder:] 
39 0x10291ff0 Retain 28 UIKit -[UIRuntimeConnection initWithCoder:] 
40 0x10291ff0 Retain 29 UIKit -[UIRuntimeConnection initWithCoder:] 
41 0x10291ff0 Retain 30 UIKit UINibDecoderDecodeObjectForValue 
42 0x10291ff0 Retain 31 UIKit UINibDecoderDecodeObjectForValue 
43 0x10291ff0 Retain 32 UIKit UINibDecoderDecodeObjectForValue 
44 0x10291ff0 Retain 33 UIKit UINibDecoderDecodeObjectForValue 
45 0x10291ff0 Release 32 UIKit -[UINib instantiateWithOwner:options:] 
46 0x10291ff0 Release 31 UIKit +[UIProxyObject removeMappingsForCoder:] 
47 0x10291ff0 Release 30 UIKit +[UIProxyObject removeMappingsForCoder:] 
48 0x10291ff0 Release 29 UIKit -[UINibDecoder finishDecoding] 
49 0x10291ff0 Release 28 UIKit -[UINibDecoder finishDecoding] 
50 0x10291ff0 Release 27 UIKit -[UINibDecoder finishDecoding] 
51 0x10291ff0 Release 26 UIKit -[UINibDecoder finishDecoding] 
52 0x10291ff0 Release 25 UIKit -[UINibDecoder finishDecoding] 
53 0x10291ff0 Release 24 UIKit -[UINibDecoder finishDecoding] 
54 0x10291ff0 Release 23 UIKit -[UIRuntimeConnection dealloc] 
55 0x10291ff0 Release 22 UIKit -[UIRuntimeConnection dealloc] 
56 0x10291ff0 Release 21 UIKit -[UIRuntimeConnection dealloc] 
57 0x10291ff0 Release 20 UIKit -[UIRuntimeConnection dealloc] 
58 0x10291ff0 Release 19 UIKit -[UIRuntimeConnection dealloc] 
59 0x10291ff0 Release 18 UIKit -[UIRuntimeConnection dealloc] 
60 0x10291ff0 Release 17 UIKit -[UIRuntimeConnection dealloc] 
61 0x10291ff0 Release 16 UIKit -[UIRuntimeConnection dealloc] 
62 0x10291ff0 Release 15 UIKit -[UIRuntimeConnection dealloc] 
63 0x10291ff0 Release 14 UIKit -[UIRuntimeConnection dealloc] 
64 0x10291ff0 Release 13 UIKit -[UIRuntimeConnection dealloc] 
65 0x10291ff0 Release 12 UIKit -[UIRuntimeConnection dealloc] 
66 0x10291ff0 Release 11 UIKit -[UIRuntimeConnection dealloc] 
67 0x10291ff0 Release 10 UIKit -[UIRuntimeConnection dealloc] 
68 0x10291ff0 Release 9 UIKit -[UIRuntimeConnection dealloc] 
69 0x10291ff0 Release 8 UIKit -[UIRuntimeConnection dealloc] 
70 0x10291ff0 Release 7 UIKit -[UIRuntimeConnection dealloc] 
71 0x10291ff0 Release 6 UIKit -[UIRuntimeConnection dealloc] 
72 0x10291ff0 Release 5 Foundation -[NSAutoreleasePool drain] 
73 0x10291ff0 Retain 6 MyApp -[SSPullToRefreshView initWithScrollView:delegate:] 
74 0x10291ff0 Release 5 MyApp -[SSPullToRefreshView initWithScrollView:delegate:] 
75 0x10291ff0 Retain 6 UIKit -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] 
76 0x10291ff0 Retain 7 libsystem_sim_blocks.dylib _Block_object_assign 
77 0x10291ff0 Retain 8 libsystem_sim_blocks.dylib _Block_object_assign 
78 0x10291ff0 Release 7 Foundation __NSFireDelayedPerform 
79 0x10291ff0 Release 6 UIKit -[UIStoryboardSegue dealloc] 
80 0x10291ff0 Release 5 Foundation __NSFireDelayedPerform 
81 0x10291ff0 Release 4 UIKit -[UIStoryboardScene dealloc] 
82 0x10291ff0 Retain 5 UIKit __91-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]_block_invoke_0238 
83 0x10291ff0 Release 4 UIKit __destroy_helper_block_250 
84 0x10291ff0 Release 3 MyApp __destroy_helper_block_ 
85 0x10291ff0 Release 2 UIKit -[UIWindowController transitionViewDidComplete:fromView:toView:removeFromView:] 
86 0x10291ff0 Retain 3 UIKit -[UIViewController _dismissViewControllerWithTransition:from:completion:] 
87 0x10291ff0 Retain 4 UIKit __91-[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:]_block_invoke_0238 
88 0x10291ff0 Retain 5 UIKit -[UIViewController _didFinishDismissTransition] 
89 0x10291ff0 Retain 6 UIKit -[UIApplication _removeViewControllerForLockingStatusBarTintColor:] 
90 0x10291ff0 Release 5 UIKit -[UIApplication _removeViewControllerForLockingStatusBarTintColor:] 
91 0x10291ff0 Release 4 UIKit -[UIApplication _removeViewControllerForLockingStatusBarTintColor:] 
92 0x10291ff0 Release 3 UIKit -[UIViewController setChildModalViewController:] 
93 0x10291ff0 Release 2 UIKit -[UIViewController _didFinishDismissTransition] 
94 0x10291ff0 Release 1 UIKit -[UIWindowController transitionViewDidComplete:fromView:toView:removeFromView:] 
95 0x10291ff0 Release 0 UIKit -[UIViewController _dismissViewControllerWithTransition:from:completion:] 
96 0x10291ff0 Zombie -1 UIKit -[UIScrollView(UIScrollViewInternal) _delegateScrollViewAnimationEnded] 

- редактировать -

Вот как я использую AFNetworking для извлечения данных на каждой странице моего приложения:

[[APIClient sharedClient] getPath:request 
          parameters:params 
           success:^(AFHTTPRequestOperation *operation, id responseObject) { 
            [SVProgressHUD dismiss]; 
            [self.pullToRefreshView finishLoading]; 

            ... read data ...          

           } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
            [SVProgressHUD showErrorWithStatus:error.localizedDescription]; 
           }]; 

Там нет воли/didUnload методы, только это один :

- (void)viewWillDisappear:(BOOL)animated{ 
    [SVProgressHUD dismiss]; 
    [_pubnub unsubscribeFromChannel: self.pro.channel]; 
} 
+0

вы можете разместить код из пользовательского контроллера представления как dealloc и viewDidUnload: – nkongara

+0

Ваш код, выполняющий «respondsToSelector»? Если да, можете ли вы показать этот фрагмент? И существует ли какое-либо асинхронное выполнение с AFNetworking? Вы используете блоки где угодно? – jbbenni

+0

* Приблизительно такая же проблема. * –

ответ

0

Я думаю, это из-за методов делегатов AFNetworking. Вы, вероятно, используете методы делегирования AFNetworking для получения содержимого из вашего бэкэнд. Вы можете очистить делегат от него, когда освободится ваш CustomViewController. Итак, добавьте следующую привязку кода к методу dealloc вашего CustomViewContoller.

- (void)dealloc 
{ 
    ... 
    networkingInstance.delegate = nil; 
    [super dealloc]; 
} 
+0

Я согласен, что проблема может возникнуть в вызове API. Я добавил код, который я использую для получения данных на каждом экране приложения. – Nanego

+0

Мой sharedClient расширяет AFHTTPClient. Я не вижу, как очистить делегат от него ... но, возможно, я должен найти способ сказать ему, что текущий запрос должен быть закрыт. – Nanego

+0

Просьба узнать, где вы устанавливаете этот экземпляр CustomViewController в качестве делегата или что-то вроде sharedClient. – Pei

Смежные вопросы