Facebook iOs sdk iphone: a challenge from multiple perspectives

I followed the official manual from facebook dev doc for implementing SSO from my iphone application, but they are all in the same controller that supports the Facebook class. Now consider that I want to enter the first view control of one navigation controller, and then call the api graph from the third view manager of the same navigation controller. I think I can share the variable from one controller to another, but I want to know if there are any β€œclassic” ways to do this. In fact, what I want to do in something like: At the beginning of the application, I want to log in and then call the api (or fql) graph where I need to in my application.

thanks

+4
source share
2 answers

I just did this:

in the file YourApp_AppDelegate.h

#import "FBConnect.h" Facebook *facebook; @property (nonatomic, retain) Facebook *facebook; 

In the program 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 function viewController.m viewDidLoad:

 appDelegate = (YourApp_AppDelegate *)[[UIApplication sharedApplication] delegate]; 

Now, anytime you want to link to your Facebook singleton, just refer to it like this:

 [appDelegate.facebook authorize:nil delegate:self]; 
+10
source
 facebook = [[Facebook alloc] initWithAppId:@"YOUR_FACEBOOK_API" andDelegate:self]; 

Here is how it looks on my code :)

-1
source

Source: https://habr.com/ru/post/1344108/


All Articles