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 6339877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:43:50+00:00 2026-05-24T19:43:50+00:00

I have been playing with the Facebook iOS API the past days and I

  • 0

I have been playing with the Facebook iOS API the past days and I got some questions. If I have two distinct view controllers that both need to use the Facebook object how should I share the object? And is it necessary to share it at all? I have been thinking of making a singleton. What I thought of doing was making a class “SocialMedia” that has a class method named “sharedFacebook”.

Then I have another class named PREFIXFacebook where I conform to the session protocol and make an object. This class has an attribute named facebook. Then I instantiate this class in the SocialMedia class and send the method “facebook” to it and assign the returned object to the static Facebook variable in SocialMedia. Is that bad design? I have not been doing much singletons before, and I don’t even know if it is necessary, but I don’t want to duplicate the code.

Another approach would be to do this in the app delegate, but I read a post here on stack overflow and heard in one of the stanford iOS videos that it is bad to do such things with the global. Any thoughts?

  • 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-05-24T19:43:53+00:00Added an answer on May 24, 2026 at 7:43 pm

    As with most things, global variables are not bad in moderation. If you abuse them, you will be running short on Memory, but I think it is justified in this case. A singleton is essentially a global variable and I believe your plan here is a good one. Not only will it help you with Facebook, but it will help with other single-login sites such as Twitter and Google+.

    To keep things with a small footprint, you don’t want to store a million things in the Singleton class. Try to only store the bare minimum needed to avoid re-authenticating. This probably means only the Facebook object itself, and not an additional wrapper class for it.

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

Sidebar

Related Questions

I have been playing with Facebook Graph API around a week, and I still
I have been playing around with NSURLConnection. Now I'm trying to grab some data
I have been playing with Compact Framework lately and i need some advice. I
I've been playing around the Facebook Graph API for a while now. I'm trying
I have been playing with Node.js for some time. I have the following piece
I have been playing around in PHP with it and got something to work,
I have been playing around with php-gtk recently and in the past I have
I have been playing with the Command Window in Visual Studio (View->Other Windows->Command Window).
I've been playing around with the iOS Facebook SDK and I'm getting a bit
I have been playing around with the youtube API and node.js, so far I

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.