0

I've had some crash reports from bugsense for my iOS app I'm not able to reproduce and so not to debug. It happens more than 200 times a day so I guess it's quite serious.

I've read something about NSZombie but I'm not able to reproduce the crash so I guess it's useless. Here is a crash report:

SIGSEGV
0 libobjc.A.dylib 0x3aa515b0 objc_msgSend + 15
1 UIKit 0x34d493df + 294
2 UIKit 0x34cae469 + 52
3 QuartzCore 0x34926099 + 160
4 QuartzCore 0x34925ff1 + 64
5 IOMobileFramebuffer 0x36ba1fd7 + 154
6 IOKit 0x33920449 IODispatchCalloutFromCFMessage + 192
7 CoreFoundation 0x32d035db + 118
8 CoreFoundation 0x32d0e173 + 34
9 CoreFoundation 0x32d0e117 + 138
10 CoreFoundation 0x32d0cf99 + 1384
11 CoreFoundation 0x32c7febd CFRunLoopRunSpecific + 356
12 CoreFoundation 0x32c7fd49 CFRunLoopRunInMode + 104
13 GraphicsServices 0x368562eb GSEventRunModal + 74
14 UIKit 0x34b95301 UIApplicationMain + 1120
15 My Bet main (main.m:16) Live 0x000705e7 0x6d000 + 13799

On some similar threads they believe the problem can be in UIAlertView, so here is an example on how I use them: in file.h

UIAlertView *alertView;

in file.m

-(void)wait{
UIActivityIndicatorView * activityView = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityView.frame = CGRectMake(121.0f, 50.0f, 37.0f, 37.0f);
[activityView startAnimating];
alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Searching...", @"") message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
[alertView addSubview:activityView];
[alertView show];
[NSThread detachNewThreadSelector:@selector(function) toTarget:self withObject:nil];
}
-(void)function{
// Do some web request
[alertView dismissWithClickedButtonIndex:0 animated:NO];
if(response == nil){
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Timeout", @"") message:NSLocalizedString(@"Connection timeout", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"Close", @"") otherButtonTitles:nil ];
    [alert show];
}
}

Any hint on how I can procede to solve this? Thanks

4

1 回答 1

2

崩溃可能是由于关闭并显示UIAlertView来自其他线程的。

永远不要UI在其他线程中执行任务。UI任务应该在主线程中完成。

更改function如下:

-(void)function
{
 // Do some web request

 dispatch_async(dispatch_get_main_queue(), ^{
    [alertView dismissWithClickedButtonIndex:0 animated:NO];
    if(response == nil)
    {
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Timeout", @"") message:NSLocalizedString(@"Connection timeout", @"") delegate:nil cancelButtonTitle:NSLocalizedString(@"Close", @"") otherButtonTitles:nil ];
    [alert show];
    }
  });
}
于 2013-04-29T13:44:14.580 回答