Friday, July 8, 2011

FBConnect using other ViewController



in the YourApp_AppDelegate.h
#import "FBConnect.h"
Facebook *facebook;
@property (nonatomic, retain) Facebook *facebook;
In the YourApp_AppDelegate.m
@synthesize facebook;
Then in your application didFinishLaunchingWithOptions: function:
facebook = [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_API"];
From your viewController.h (any of them),
#import "YourApp_AppDelegate.h"
YourApp_AppDelegate *appDelegate;
And then, in your viewController.m viewDidLoad function:
appDelegate = (YourApp_AppDelegate *)[[UIApplication sharedApplication] delegate];
Now, anytime you want to refer to your Facebook singleton, just refer to it like:
[appDelegate.facebook authorize:nil delegate:self];

No comments:

Post a Comment