I have an app that, according to crash logs, is crashing on startup while checking if the user is logged into Facebook on the device. The problem is that I cannot reproduce this crash, and it happens on different devices. So far, I have only seen this crash in pre-iOS 6 operating systems. The earliest iOS supported by my app is 4.3.
Here is the code, if anyone can provide a clue as to why this method sometimes fails (and most times does not!)
The error I get is EXC_BAD_ACCESS (SIGSEGV);KERN_INVALID_ADDRESS at 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;
}