Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:56:29+00:00 2026-06-02T22:56:29+00:00

I have a facebook variable in my ViewController that I want to refer to

  • 0

I have a facebook variable in my ViewController that I want to refer to in my AppDelegate method. How do I do this?

In my AppDelegate I want to put this, since it uses UIApplication and all other refs are in this class:

    // For iOS 4.2+ support
    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
      sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
        return [facebook handleOpenURL:url]; 
    }

The facebook variable is in my ViewController .h file:

    #import <UIKit/UIKit.h>
    #import "FBConnect.h"

    @interface ImportPicViewController : UIViewController <FBSessionDelegate, FBDialogDelegate>{
        Facebook *facebook;
    }
    @property (nonatomic, retain) Facebook *facebook;
    @end

and synthesized in the .m file:

    @implementation ImportPicViewController
    @synthesize facebook;

But it is alloc init in the ViewController:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
        facebook = [[Facebook alloc] initWithAppId:@"224207854355440" andDelegate:self];

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:56:36+00:00Added an answer on June 2, 2026 at 10:56 pm

    I have a facebook variable in my ViewController that I want to refer
    to in my AppDelegate method.

    That doesn’t sound like a good plan — it’ll mean that your app delegate is dependent on this view controller.

    A better design might have the app delegate create the instance of Facebook and keep a reference to it in its own ivar. Then, when it creates the view controller, it can pass in a reference to the instance of Facebook. This way, both the app delegate and the view controller are using the same Facebook object, but they’re not trying to access each other’s instance variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To put it simply I have this variable which carries a hyperlink: $test3 =
I have Facebook in an Iframe for the convenience of my clients. But all
I have facebook connect button on a page of my site and I want
I am doing this in order to have Facebook like button in my page:
I have a facebook game application that is released at facebook platform at the
I have a facebook connect site using the c# facebook toolkit. I want to
I have an array and a variable, I want to check if any of
related (sort of) to this question. I have written a script that will loop
I have added a facebook button to my company's site so that people can
I have a MySQL database that I want to update with a response value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.