我正在使用swrevealviewController从一个视图滑动到另一个视图。 但我的应用程序随机崩溃,当我从一个视图滑动到另一个视图时,在每个视图上,都有服务器调用显示视频列表。
- (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;
}
我的应用程序在上面的方法中随机崩溃,并在日志中给出错误,如下所示:: [viewController retain]:消息发送到解除分配的实例0xa081994e
我也是通过使用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)
请帮助我,先谢谢。
答案 0 :(得分:0)
您正在尝试使用内存中不再存在的视图控制器,因此首先打开NSZombies以找出发生这种情况的位置How to enable NSZombie in Xcode?
其次在致电你的代表之前,你应该检查以确保它不是
- (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;
}
答案 1 :(得分:0)
尝试在dealloc中发布responseData,如下所示
-(void)dealloc{
[repsonseData release];
responseData = nil;
}
并在调用方法之前检查是否设置了responseDelegate