iOS - 集成Facebook框架

时间:2012-09-03 14:49:24

标签: ios facebook

在我的iOS应用程序中,我成功整合了最新的facebook框架 如果“facebook”应用程序不在我的iphone上,它的工作正常。如果应用程序不在我的iphone上,在身份验证期间,它会打开浏览器并正确进行身份验证 但是,如果Facebook应用程序在我的iphone上,经过身份验证和返回我的应用程序后,它崩溃并出现以下错误:
由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [SBJsonParser errorTrace]:无法识别的选择器发送到实例0x2d9f60'


我看过facebook提供的样本并在我的应用程序中实现了相同的样本。有人可以指出我可能是什么问题吗?

2 个答案:

答案 0 :(得分:1)

这在黑暗中有点刺痛但我认为你可能在errorTrace的实例上调用方法SBJsonParser:)

可能发生的事情是你在早期发布的内容上调用errorTrace。浏览facebook重新打开您的应用并找到errorTrace的来电时触发的代码路径。在它之前设置一个断点,并环顾四周看看有什么不对。

答案 1 :(得分:0)

如果您只想在iOS 6.0中分享内容,那么您可以使用社交和帐户框架,并使用以下代码通过iPhone内部登录来完成工作

-(void)facebook_Share_in_IOS6.0{

    if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) //check if Facebook Account is linked
    {
        mySLComposerSheet = [[SLComposeViewController alloc] init]; //initiate the Social Controller
        mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //Tell him with what social plattform to use it, e.g. facebook or twitter
        [mySLComposerSheet setInitialText:[NSString stringWithFormat:@"Test",mySLComposerSheet.serviceType]]; //the message you want to post
    //    [mySLComposerSheet addImage:yourimage]; 

        [self presentViewController:mySLComposerSheet animated:YES completion:nil];
    }else{
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Attention" message:@"First Set your facebook account. To post your answer to facebook" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }
    [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
        NSString *output;
        switch (result) {
            case SLComposeViewControllerResultCancelled:
                output = @"Action Cancelled";
                break;
            case SLComposeViewControllerResultDone:
                output = @"Post Successfull";
                break;
            default:
                break;
        } //check if everything worked properly. Give out a message on the state.
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
    }];
}