根据崩溃日志,我有一个应用程序在启动时崩溃,同时检查用户是否在设备上登录 Facebook。问题是我无法重现此崩溃,并且它发生在不同的设备上。到目前为止,我只在 iOS 6 之前的操作系统中看到过这种崩溃。我的应用程序支持的最早的 iOS 是 4.3。
这是代码,如果有人可以提供有关此方法有时会失败的原因(而且大多数时候不会!)
我得到的错误是 EXC_BAD_ACCESS (SIGSEGV);KERN_INVALID_ADDRESS 在 0x00000000。
+ (BOOL)loggedIntoServiceOnDevice:(int)socialService {
__ENTERING_METHOD__
BOOL loggedIntoServiceOnDevice = NO;
ACAccountStore *accountStoreHere = [[NSClassFromString(@"ACAccountStore") alloc] init];
ACAccountType *accountType;
ACAccountType *accountType2;
if (accountStoreHere) {
if (socialService == FACEBOOK_SERVICE) {
ACAccountType *accountType = [accountStoreHere accountTypeWithAccountTypeIdentifier:@"com.apple.facebook"];
Class slComposeController = NSClassFromString(@"SLComposeViewController");
if (accountType && slComposeController != nil)
{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {
loggedIntoServiceOnDevice = YES;
}
}
}
else if (socialService == TWITTER_SERVICE) {
ACAccountType *accountType = [accountStoreHere accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
if (accountType)
{
Class slComposeController = NSClassFromString(@"SLComposeViewController");
if ([TWTweetComposeViewController canSendTweet] || slComposeController != nil) {
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
loggedIntoServiceOnDevice = YES;
}
}
}
}
}
[accountStoreHere release];
return loggedIntoServiceOnDevice;
}