我刚刚这样做了:
在 YourApp_AppDelegate.h 中
#import "FBConnect.h"
Facebook *facebook;
@property (nonatomic, retain) Facebook *facebook;
在 YourApp_AppDelegate.m 中
@synthesize facebook;
然后在您的应用程序中 didFinishLaunchingWithOptions: 函数:
facebook = [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_API"];
从你的 viewController.h (其中任何一个),
#import "YourApp_AppDelegate.h"
YourApp_AppDelegate *appDelegate;
然后,在 viewController.m viewDidLoad 函数中:
appDelegate = (YourApp_AppDelegate *)[[UIApplication sharedApplication] delegate];
现在,任何时候你想引用你的 Facebook 单例,只需这样引用它:
[appDelegate.facebook authorize:nil delegate:self];