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

  • Home
  • SEARCH
  • 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 8369265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:36:00+00:00 2026-06-09T13:36:00+00:00

I have a TabBar layout and in the Home tab i have a button

  • 0

I have a TabBar layout and in the Home tab i have a button “Connect” which when pressed sends an action to the class TransferViewController to create a GameKit Session. Then i have another tab called Send which has a button that says “Send File” which when pressed sends an action to the class TransferViewController also which uses the “Session” variable that was setup using connect to send a file but since it is a different tab it creates a new instance of the Controller and it wants me to connect again but the button is on the Home tab.

Is there anyway that I can have one Controller for two tabs without having two instances? I want the user to click connect on the Home tab then switch to the Send tab and press Send File and use the variables setup by connect on the other tab. I’m sorry if this is confusing.

  • 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-09T13:36:02+00:00Added an answer on June 9, 2026 at 1:36 pm

    This is not confusing at all – in fact, this comes up all the time. The way this works in model-view-controller systems is that you set up a model class, make it a singleton, and add references to that singleton in all controllers that need to share the data.

    Model.h

    @interface Model : NSObject
    @property (nonatomic, readwrite) Session *session;
    -(id)init;
    +(Model*)instance;
    @end
    

    Model.m

    @implementation Model
    @synthesize isMultiplayer;
    
    -(id)init {
        if(self=[super init]) {
            self.session = ...; // Get the session
        }
        return self;
    }
    
    +(Model*)instance {
        static dispatch_once_t once;
        static Model *sharedInstance;
        dispatch_once(&once, ^{
            sharedInstance = [[self alloc] init];
        });
        return sharedInstance;
    }
    @end
    

    Now you can use the shared session in your controller code: import "Model.h", and write

    [[Model instance].session connect];
    [[Model instance].session sendAction:myAction];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TabBar Control with 3 tab, i need to add controls(Button,Label) dynamically
I have a tabbar application. And the item of first tab is Navigation Controller.
I have a tabBar, and I want to customise the items in the tab
I have a TabBar App. I have created a UITableView class called Schedule that
I have a TabBar which has been created programmatically. In the view controllers of
I have a tabbar controller and on touching a button in one of view's
I have a layout question for Tab Navigators in Adobe Flex 3. Is it
I have a tab controller, which contains a navigation controller which again contains a
I have a Tab Layout with four tabs. Navigation betweeen them works fine, but
hii... I am making a view based application in which I have tabbar controller

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.