简体   繁体   English

如何解决IOS设备上的应用程序随机崩溃?

[英]How to resolve randomly app crash on IOS Device?

I am using swrevealviewController for sliding from one view to another. 我正在使用swrevealviewController从一个视图滑动到另一个视图。 But My app is crashing randomly , When I sliding from one view to another , On every view , There is server call for showing video list. 但是我的应用程序随机崩溃,当我从一个视图滑动到另一个视图时,在每个视图上,都有服务器调用以显示视频列表。

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{

    //NSLog(@"connection did finish loading %@",responseData);
    //NSString *str = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
    //NSLog(@"tdshjfhdkh %@",str);

    [self.resopnseDelagate carryData:responseData];
    responseData = nil;
}

My app is crash in above method randomly and give an error in log as given bellow :: [viewController retain]:message sent to deallocated instance 0xa081994e 我的应用程序在上述方法中随机崩溃,并在给定以下错误的情况下给出了错误提示::: [viewController keep]:消息发送到已释放实例0xa081994e

I am also to debug this issue by using Crashlytic ,But unable to understand their log as given below : 我也使用Crashlytic来调试此问题,但无法理解其日志,如下所示:

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x3a78152c objc_retain + 11
1  DemoApp                       0x000d2c81 -[Connection connectionDidFinishLoading:] (Connection.m:76)
2  Foundation                     0x3341a6fd __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 16
3  Foundation                     0x3335a1f9 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 200
4  Foundation                     0x3335a115 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 60
5  CFNetwork                      0x327bc45f ___delegate_didFinishLoading_block_invoke_0 + 26
6  CFNetwork                      0x327bbb43 ___withDelegateAsync_block_invoke_0 + 54
7  CFNetwork                      0x327e3fcb ___performAsync_block_invoke_068 + 18
8  CoreFoundation                 0x32a2574d CFArrayApplyFunction + 176
9  CFNetwork                      0x327e442b RunloopBlockContext::perform() + 74
10 CFNetwork                      0x3274803d MultiplexerSource::perform() + 188
11 CoreFoundation                 0x32ab4683 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
12 CoreFoundation                 0x32ab3ee9 __CFRunLoopDoSources0 + 212
13 CoreFoundation                 0x32ab2cb7 __CFRunLoopRun + 646
14 CoreFoundation                 0x32a25ebd CFRunLoopRunSpecific + 356
15 CoreFoundation                 0x32a25d49 CFRunLoopRunInMode + 104
16 GraphicsServices               0x365e92eb GSEventRunModal + 74
17 UIKit                          0x3493b301 UIApplicationMain + 1120
18 DemoApp 

                  0x000da839 main (main.m:16)

Please Help me ,Thanks in Advance. 请帮助我,谢谢。

You are trying to use a view controller that no longer exists in memory so firstly turn on NSZombies to find out where this is happening How to enable NSZombie in Xcode? 您正在尝试使用内存中不再存在的视图控制器,因此请首先打开NSZombies以了解发生这种情况的方式。 如何在Xcode中启用NSZombie?

Secondly before calling your delegate you should check to ensure its not nil 其次,在致电您的代表之前,您应该检查以确保其不为零

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{

    //NSLog(@"connection did finish loading %@",responseData);
    //NSString *str = [[NSString alloc]initWithData:responseData encoding:NSUTF8StringEncoding];
    //NSLog(@"tdshjfhdkh %@",str);

    if([self.responseDelagate respondsToSelector:@selector(carryData:)]) {
        [self.resopnseDelagate carryData:responseData];
    }
    responseData = nil;
}

try releasing responseData in dealloc like this 尝试像这样在dealloc中释放responseData

-(void)dealloc{

 [repsonseData release];
 responseData = nil;

} }

and also check whether you are setting the responseDelegate before calling a method on it 并在调用方法之前检查是否设置了responseDelegate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM