アプリで AddressBook を使用しています。バックグラウンド スレッドでアドレス帳データを取得しています。バックグラウンドからアプリを開くと、次のエラーでアプリがクラッシュします。
Application Specific Information:
[2786] was suspended with locked system files:
/private/var/mobile/Library/AddressBook/AddressBook.sqlitedb
アプリがバックグラウンドから起動した後、アプリが UIApplicationDidBecomeActiveNotification を受け取ると、バックグラウンド スレッドでアドレス帳データを取得しています。これが私のコードです
// In my ViewController.m
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appLaunchedFromBackground:)
name:UIApplicationDidBecomeActiveNotification object:nil];
// Some more code
}
-(void)appLaunchedFromBackground:(NSNotification *) notification {
NSLog(@"In appLaunchedFromBackground");
[self performSelectorInBackground:@selector(getUpdatedAddressBookData) withObject:nil];
}
-(void)getUpdatedAddressBookData {
NSLog(@"In %s",__PRETTY_FUNCTION__);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
AddressBook *addBook = [[AddressBook alloc]init];
[addBook fetchAddressBookDataInBackground];
[addBook release];
[pool drain];
}
また、アプリに CALL 機能があります。アプリから no を選択するために CALL すると、CALL の終了後に再度アプリを 2 回起動してアプリがクラッシュします。CALL には、次のコードを使用しました。
+(void)makeCallToSelectedContact:(NSString*)phoneNo{
NSMutableString *phoneNumber = [NSMutableString stringWithString:phoneNo];
[phoneNumber replaceOccurrencesOfString:@" "
withString:@""
options:NSLiteralSearch
range:NSMakeRange(0, [phoneNumber length])];
[phoneNumber replaceOccurrencesOfString:@"("
withString:@""
options:NSLiteralSearch
range:NSMakeRange(0, [phoneNumber length])];
[phoneNumber replaceOccurrencesOfString:@")"
withString:@""
options:NSLiteralSearch
range:NSMakeRange(0, [phoneNumber length])];
NSLog(@"phoneNumber => %@",phoneNumber);
if([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phoneNumber]]];
}
else {
NSLog(@"Unable to open");
[self showAlertWithTitle:@"Alert" andMessage:@"This Device Doesn't Support Call Functionality"];
}
}
クラッシュの問題を解決するにはどうすればよいですか? どんな種類の助けも大歓迎です。ありがとう。