Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It's not a singleton that you want.<br> A singleton <code>must always</code> return the <code>same instance</code>.<br> What you want is a normal class that maybe have a convenience class method to feed you some pre-populated object. </p> <p>If it's possible to create more than one instance of an object it's not a singleton anymore.</p> <p>But your singleton class could hold a variable amount of instance of other class that you wish to display.<br> So in that way what you are asking could be possible, but without the copy part on the singleton. </p> <hr> <blockquote> <p>I'm not sure where you are going with this and if it's the best way to go but here is an idea :</p> </blockquote> <p>you can have a <code>singleton</code> class that would hold an array of an other class. So you could call your <code>singleton</code> like this </p> <pre><code>TheSingletonClassName *mySingleton = [TheSingletonClassName sharedTheSingletonClassName]; OtherClass *myOtherClass = [mySingleton newOtherClassInstancePlease]; </code></pre> <p>In your <code>newOtherClassInstancePlease</code> method you implement the necessary thing to store that new object into an array, that you can distribute like this</p> <pre><code>NSArray *otherClassArray = [mySingleton allOtherClasses]; </code></pre> <p>Or NSMutableArray if you prefer.</p> <p>With that you would be able to share, create new and even delete object. if you implement the necessary method on your singleton.<br> 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.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload