简体   繁体   中英

How to resolve randomly app crash on IOS Device?

I am using swrevealviewController for sliding from one view to another. 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

I am also to debug this issue by using Crashlytic ,But unable to understand their log as given below :

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?

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

-(void)dealloc{

 [repsonseData release];
 responseData = nil;

}

and also check whether you are setting the responseDelegate before calling a method on it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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