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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:53:25+00:00 2026-06-15T22:53:25+00:00

At the moment I’m using a Singleton class to do some work but I’m

  • 0

At the moment I’m using a Singleton class to do some work but I’m wondering if there is something better.

I have an app that has a completely dynamic work flow. It uses a navigation controller but the order of the view controllers depends entirely on some data that is downloaded from our server.

The entire workflow is downloaded and saved in an array.

The “main menu” screen of the app has several choices (settings, recent, etc…) these are fixed but one of them is the dynamic one. It always starts with the same type of view controller but from then on it depends on what you choose.

Description

There are 4 different types of these dynamic controllers.

  • Table View Controller with single selection and detail indicators.
  • Table View Controller with multiple selection and checkmarks.
  • View Controller with a text field and keyboard.
  • View Controller (with other related VCs) used for searching for accounts on the server.

When you press the option “New Event” on the main menu the menu then goes off to the singleton (EventManager) and tells it to start a new event.

The singleton then pushes a single selection dynamic view on the nav controller and gives it the initial options.

From here on the singleton picks up all the selections and works out what type of view is required next.

I hope this is making sense

Anyway, I don’t like the singleton pattern here as I don’t think it should be a singleton.

What I would like is a class that I can create from a ViewController and this class will then control the pushing and popping and flow of data between a load of different view controllers. Then when you go back to the main menu this class can go away so I create a new class each time.

Is there a pattern that I can look at that will do this? Or should I stick with a singleton like I am now?

I hope this makes sense.

EDIT

Could I use a UIPageViewController for this? Then the datasource/delegate object of the UIPageViewController will take the place of the Singleton I am currently using… or something?

ADDING PHOTO FROM TWITTER REQUEST

enter image description here

Each VC along the flow has no idea what cam before it or what comes next. All they do is call back to the singleton to say “This value was selected” or “This text was entered” etc…

The singleton then stores that info and works out what comes next and pushes the next VC onto the stack.

It needs to be able to move back along the stack so the user can go back to change something etc…

It’s all working as it is I just don’t like the use of the singleton.

  • 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-15T22:53:26+00:00Added an answer on June 15, 2026 at 10:53 pm

    Lots of comments here in order of importance.

    Everything you’ve described here sounds really good, even down to the naming. “EventManager” sort of sounds like it manages all “events” in the system (so I’d expect there to be a class called Event, but that’s a tiny quibble and the name is likely still very good). There are other good designs, but I wouldn’t have any problem with yours.

    I agree that this does look like a good fit for UIPageViewController. You should certainly investigate that to see if it’s the right fit. It’s always nice to use a built-in controller if you can.

    There’s no reason to strongly avoid singletons. They are a natural part of iOS development and fairly common in good Cocoa design. They should be “shared” singletons generally (never create “strict” singletons that override +allocWithZone:). This just creates an easy-to-access instance rather than a true “singleton.” This is the way things like NSNotificationCenter work and is often a very good pattern.

    Singletons are best when many random pieces of the system need to access them directly and passing them around to everyone would be a lot of overhead (especially if many of the pieces you’d have to pass the object to don’t need it themselves). Again, think NSNotificationCenter. If the users of it are mostly contiguous (i.e. most objects you would pass it to actually need it themselves), then just create one at the start of the program and pass it around. That sounds like your situation, so your intuition about it seems good. Just de-singleton it and pass it. Easy change.

    But I’d definitely dig into UIPageViewController. It could match your problem very well.

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

Sidebar

Related Questions

At the moment I have some test code that starts something like this: CheckBoxPreference
So at the moment I have a simple reminder app that you enter some
At the moment I have a class that requires information from another class, but
There is a moment in my app, that I need to force to show
At the moment I am using a custom class derived from HashSet . There's
At the moment my server outputs HTML that looks something like this: <span class='tag'>music<a
At the moment we have a number of tables that are using newid() on
At this moment I have an application that processes a file. My workflow is:
At the moment I am using powershell hosted in an asp.net app to communicate
At this moment there is a very basic flash project that connects to 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.