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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:51:35+00:00 2026-06-10T19:51:35+00:00

Say I have a library or service which is created by an application, and

  • 0

Say I have a library or service which is created by an application, and my UIViewControllers are served from the storyboard. I would like to use dependency injection to pass those objects to the ViewControllers as they are being created.

  1. Where is the best place to define a service or class that holds commonly used utility functions? I could use a singleton but I am exploring other options, such as creating it in the first UIViewController that will be shown. The object is likely to be some logic that are used among different UIViewControllers, such as accessing the database, or access to a model shared between different controllers, or business/game logic.

  2. How do I inject that object into the first UIViewController that will be shown using the storyboard?

  3. When performing a segue, is there some way to do call an initializer of the next UIViewController to pass in a dependency? As far as I know, by the time the code reaches prepareForSeqgue, the next UIViewController to be shown has already been created.

Basically, I looking to do something like this:

-(void) hypotheticalApplicationStart
{
   self.gameLogic = [[GameLogic alloc] init];
} 

And then when the first UIViewController is created and push to be viewed:

-(void) hypotheticalDisplayFirstViewController
{
   UIViewController* controller = [[ MyView alloc] int];
   [controller setGameLogic:self.gameLogic)];

   // display controller
}

*Sorry for any code typos or syntax error, I have just began learning Objective C and IOS5 programming.

  • 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-10T19:51:36+00:00Added an answer on June 10, 2026 at 7:51 pm

    You can select any Cocoa Dependency Injection Framework on GitHub.

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

Sidebar

Related Questions

Say, I have mylibrary.ml which provides wrappings to library.c and I want to bytecode-compile
Say I have a library libfoo.so.1 , which depends (according to ldd ) on
lets say I have a library object (node1) which i have instantiated twice (mc1
Let’s say I have a library, in which I added a few Console.WriteLine(..) statements
I have a client that would like to use SkyDrive as a cloud storage
Lets say we have a native library that works with data like this: double
I have a library, say LIB, which exposes the quite a few APIs and
Let's say I have a library Lib.dll, which uses Castle.Windsor to initialize its services.
Lets say I have a library, version 1.0.0, with the following contents: public class
Using non-thread safe libraries with threads. Say I have a library that makes a

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.