0

我按照此链接中的说明进行操作 https://developers.facebook.com/docs/mobile/ios/build/

我创建了一个 iOS Facebook SDK 静态库,编译器一直说 iniWithAppId 和 Delegate 方法有问题

错误日志

2012-04-12 14:11:10.569 comman[2609:f803]-[Facebook initWithAppId:withDelegate:]:无法识别的选择器发送到实例 0x68970e0

2012-04-12 14:11:10.572 comman[2609:f803] *由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[Facebook initWithAppId:withDelegate:]:无法识别的选择器发送到实例 0x68970e0”

* First throw call stack: (0x13d7052 0x1568d0a 0x13d8ced 0x133df00 0x133dce2 0x209a 0x2c9d6 0x2d8a6 0x3c743 0x3d1f8 0x30aa9 0x12c1fa9 0x13ab1c5 0x1310022 0x130e90a 0x130ddb4 0x130dccb 0x2d2a7 0x2ea9b 0x1ff2 0x1f65)

终止调用抛出异常sharedlibrary apply-load-rules all

当前语言:自动;目前客观-c

(gdb)

#import <UIKit/UIKit.h>
#import "FBConnect.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate, FBSessionDelegate>{
           Facebook *facebook;
}

@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) Facebook *facebook;

@end

以上是我的应用程序委托标头,这是我的应用程序委托实现文件

#import "AppDelegate.h"

@implementation AppDelegate


@synthesize window = _window;
@synthesize facebook;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    facebook = [[Facebook alloc] initWithAppId:@"215686948531995" withDelegate:self];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if([defaults objectForKey:@"FBAccessTokenKey"] && [defaults objectForKey:@"FBExpirationDateKey"]){
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}

   // NSArray *permissions = [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access", nil]retain];
    if(![facebook isSessionValid]){
        [facebook authorize:nil];
    }
    // Override point for customization after application launch.
    return YES;
}

facebook 开发人员演示的方法是否仅适用于 xcode 4 或 ios 4.3?谁能给我一些建议,如何为ios5故事板编写类:3

4

2 回答 2

1
static NSString* kAppId = @"yourAppId";

_facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self];
于 2012-05-28T10:07:41.550 回答
0

我昨天自己实现了这个,它运行良好(静态 Facebook 库,使用 Storyboards)。我能看到的唯一区别(这会导致问题)是你打电话给:

facebook = [[Facebook alloc] initWithAppId:@"215686948531995" withDelegate:self];

我打电话给:

facebook = [[Facebook alloc] initWithAppId:@"215686948531995" andDelegate:self];

我相信使用withDelegate而不是的andDelegate错误会给你这个错误。

于 2012-04-14T04:47:33.050 回答