为什么MFMailComposeViewController崩溃?

Jor*_*rez 5 uikit ios

调用"[MFMailComposeViewController canSendMail]"后,我看到一个奇怪的崩溃.

我无法重现它,它来自iTunesConnect.从主线程调用该方法(canSendMail),此时,我没有对地址簿做任何事情.

任何想法/建议将非常感激.

提前致谢!

注意:这发生在iOS 5.1.1中.

Exception Type:  SIGABRT
Exception Codes: #0 at 0x3583232c
Crashed Thread:  0

Thread 0 Crashed:
0   libsystem_kernel.dylib              0x3583232c __pthread_kill + 8
1   libsystem_c.dylib                   0x347e729f abort + 95
2   AppSupport                          0x3133cc57 abortAfterFailingIntegrityCheck + 39
3   AppSupport                          0x3133ceef runIntegrityCheckAndAbort + 535
4   AppSupport                          0x3133d025 checkResultWithStatement + 113
5   AppSupport                          0x3133ea13 _connectAndCheckVersion + 1059
6   AppSupport                          0x3133eab7 CPSqliteDatabaseConnectionForWriting + 43
7   AppSupport                          0x3133eb8d CPSqliteDatabaseRegisterFunction + 21
8   AddressBook                         0x337873f7 ABCDBContextCreateWithPathAndAddressBook + 215
9   AddressBook                         0x3377b429 ABCCreateAddressBookWithDatabaseDirectoryAndForceInProcessMigrationInProcessLinkingAndResetSortKeys + 233
10  AddressBook                         0x33789cd7 ABAddressBookCreate + 15
11  Message                             0x31072453 MFThreadLocalAddressBook + 87
12  MessageUI                           0x313a5471 +[MFMailComposeController initialize] + 9
13  libobjc.A.dylib                     0x35edc973 _class_initialize + 239
14  libobjc.A.dylib                     0x35edc87b prepareForMethodLookup + 143
15  libobjc.A.dylib                     0x35edc747 lookUpMethod + 47
16  libobjc.A.dylib                     0x35edc713 _class_lookupMethodAndLoadCache3 + 19
17  libobjc.A.dylib                     0x35edbfcb objc_msgSend_uncached + 27
18  MessageUI                           0x313a5455 +[MFMailComposeViewController canSendMail] + 33
Run Code Online (Sandbox Code Playgroud)

=============

更新:

导致此崩溃的代码片段如下:

-(IBAction)helpButtonPressed
{
    if([MFMailComposeViewController canSendMail])
    {   
        NSString* mail  = self.feedbackSettings[@"mail"];
        NSString* title = self.feedbackSettings[@"title"];

        MFMailComposeViewController* mailComposer = [[MFMailComposeViewController alloc] init];
        mailComposer.mailComposeDelegate = self;
        mailComposer.toRecipients = @[ mail ];
        mailComposer.subject = title;

        [self presentViewController:mailComposer animated:YES completion:nil];
        [mailComposer release], mailComposer = nil;
    }
    else
    {
        [UIAlertView showAlertViewWithTitle:nil message:NSLocalizedString(@"Please, setup a mail account in your phone first.", nil) buttonTitle:NSLocalizedString(@"OK", nil)];
    }
}
Run Code Online (Sandbox Code Playgroud)

JLu*_*ell 7

我最近看到了运行iOS 5的客户的崩溃报告,该报告基本上与此版本重复.我最好的猜测是它是由一个损坏的地址簿数据库引起的.请注意,崩溃发生在调用中ABAddressBookCreate(这是一个误导性的名称;它更像是打开); 你没有做任何应该能够引起这种情况的事情.

如果您可以控制地址簿,并且在同一地点进行同步,则可以尝试关闭同步,删除所有联系人,然后再将它们同步(当然先备份).

MFMailComposeViewController 正在访问地址簿,可能是为了向用户提供:地址.

[尼特:在你退出一个函数之前,自动变量没有多大意义.]