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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:39:48+00:00 2026-05-27T06:39:48+00:00

I would like to take a singleton class that gets used by multiple view

  • 0

I would like to take a singleton class that gets used by multiple view controllers, copy it, and save it to an array that will be displayed in another view controller with a table view that will show multiple instances of that class. This array will eventually be archived to be retrieve with the same data.

Before I attempt this, is there a way I can duplicate this singleton instance, save it to the array, re-initialize it for the next use, and so on (without getting the same exact previously uninitialized object)?

  • 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-27T06:39:49+00:00Added an answer on May 27, 2026 at 6:39 am

    It’s not a singleton that you want.
    A singleton must always return the same instance.
    What you want is a normal class that maybe have a convenience class method to feed you some pre-populated object.

    If it’s possible to create more than one instance of an object it’s not a singleton anymore.

    But your singleton class could hold a variable amount of instance of other class that you wish to display.
    So in that way what you are asking could be possible, but without the copy part on the singleton.


    I’m not sure where you are going with this and if it’s the best way to
    go but here is an idea :

    you can have a singleton class that would hold an array of an other class. So you could call your singleton like this

    TheSingletonClassName *mySingleton = [TheSingletonClassName sharedTheSingletonClassName];
    OtherClass *myOtherClass = [mySingleton newOtherClassInstancePlease];
    

    In your newOtherClassInstancePlease method you implement the necessary thing to store that new object into an array, that you can distribute like this

    NSArray *otherClassArray = [mySingleton allOtherClasses];
    

    Or NSMutableArray if you prefer.

    With that you would be able to share, create new and even delete object. if you implement the necessary method on your singleton.
    But again don’t copy a singleton, if the singleton is well implemented sending it a copy call should throw an exception, or return the single singleton instance that exists.

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

Sidebar

Related Questions

I would like to take the following array and generate a new array that
I would like to take a stack of images (or potentially an array of
I would like to take a field and replace all characters that are not
What I would like to take ownership of a hid device that may already
I would like to take this script and have it filter an array of
I would like to take bites out of a list (or array) of a
I would like to take advantage of the features that Maven provides for managing
Long story short, I would like to take my usercontrols that are loaded dynamically
I would like to take a pascal-cased string like CountOfWidgets and convert it into
I would like to take a string representation of a set and parse it.

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.