gpt4 book ai didi

facebook - 检查设备是否已登录服务时无法重现应用程序崩溃

转载 作者:行者123 更新时间:2023-12-03 15:56:30 25 4
gpt4 key购买 nike

根据崩溃日志,我有一个应用程序在启动时崩溃,同时检查用户是否已在设备上登录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;
}

最佳答案

由于[TWTweetComposeViewController canSendTweet]返回YES,因此在iOS 5中也执行了以下行,因此不评估OR检查的第二部分,因为第一部分已经返回YES:

[SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]

您可能需要将那些if语句更改为以下内容:
if ([TWTweetComposeViewController canSendTweet] ||
(
slComposeController != nil &&
[SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]
)
) {

这可以确保仅在类实际存在时才使用 SLComposeViewController

关于facebook - 检查设备是否已登录服务时无法重现应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13676023/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com