iphone - How do I persist a Facebook instance in multiple IOS view classes? -


I have been a reader of the stack overflow for some time and am eager to participate! On the question ...

I'm programming for about 10 years, but new to iOS programming; Objective c.

I'm trying to create an application that requires a Facebook login when the app opens, then a view needs to be loaded with the logo and a Facebook login button. I can do this and I can work with no problem. After logging in with Facebook, my application will send an API call to my server and authenticate them with my system and send a callback with their system permissions. If it comes back that they have the right permission to advance, then they will send a tabbed interface with a view. I also have a tabbed interface working

I have created a First VCA controller to handle Facebook login button, and look at the controller for each tab.

MyAppDelegate.m file will contain something like this: - (BOOL) Application: (UIApplication *) Application FinishLaunchingWithOptions: (NSDictionary *) Launch Option {/ / Init Facebook & amp; Send initial view with login button facebook = [[Facebook invoke] initWithAppId: @ "MYAPPID"]; [Self. Window Preview: FirstviewController Observation]; [Self. Windows and knowledgeable]; // Code to check permissions from the webserver (if permissions & amp; _isLoggedIn) {// add a view of the tab bar controller in the window and display [self Window Adsview: TabBr Controller See]; [Self. Windows and knowledgeable]; } Else // access denied view return Yes; }

Now, I need to call the Facebook login method in FirstviewControler ...

  [facebook authorize: noil delegate: self];   

1) How can I use Facebook instances in MyAppDelegate? (I also need access to all other views.) Can I create a representative / protocol to access it from MyAppDelegate?

2) Am I doing this in an incredibly silly manner? If so, help bring an amateur IOS programmer on the right track.

3) How can I use the "delegate" logic in the Facebook method? I'm not sure that I understand it very well.

Thank you, Matt

I have never used the Facebook Object C-CP API But I can give you some insight into setting up global access for your Facebook instances. You can get an app representative like this:

  MyAppDelegate * appDelegate = (MyAppDelegate *) [[UIApplication shared application] representative];   

Unless you have a public method to access facebook ivar / property of > MyAppDelegate You can get:

  Facebook * theFacebook = [App Delegate facebook];   

This will not give you any warnings unless you have #import "MyAppDelegate.h" anywhere. Take a look at -Author: Representative: , as

. The representative should implement the FBSessionDelegate protocol to pass that method.

To know more about the delegation in general, check out.

Edit

To be really clear here, you should put it in your MyAppDelegate.h file: / P>

  // MyAppDelegate HK # import & lt; UIKit / UIKit.h & gt; @ Class facebook; @ Interface MyAppDelegate: NSObject {UIWindow * window; UITabBarController * Tabbar Controller; Facebook Facebook; } @ Property (Nonomatic, Retaining) IBOutlet UIWindow * Window; @protecti (nonomatic, reserved) IBOutlet UITabBarController * Tabbar Controller; @property (nonatomic, retaining) Facebook * Facebook; @end   

and MyAppDelegate.m

  // MyAppDelegate.m #import "MyAppDelegate.h" #import "Facebook .h "@imipilation MyAppDelegate @ synthesis window; @injection tab tab controller; @ Synthesis Facebook; - (BOOL) Application: (UIApplication *) Application FinishLaunchingWithOptions: (NSDictionary *) Launch Option. ... Your implementation here ... * /} / .... More methods ... * / @end    

Comments