• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: how to make an object with a single unique instance like NSNull?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to make an object with a single unique instance like NSNull?


  • Subject: Re: how to make an object with a single unique instance like NSNull?
  • From: p3consulting <email@hidden>
  • Date: Wed, 30 Mar 2005 20:56:49 +0200


Le 29 mars, 2005, à 16:48, Finlay Dobbie a écrit :

On Tue, 29 Mar 2005 09:42:22 -0500, Johnny Deadman
<email@hidden> wrote:
I need to make a version of NSNull for my own purposes (it has to be
a coredata* object so NSNull won't suffice) but I can't figure out
NSNull's trick of only having a single unique instance. In other words

[NSNull null]

always returns the same instance of NSNull no matter how many times
you call it.

How do I do this?

<http://developer.apple.com/documentation/Cocoa/Conceptual/ CocoaObjects/Articles/CreateSingleton.html>




Bug fix:

+ (id)allocWithZone:(NSZone *)zone
{
@synchronized(self) {
if (sharedGizmoManager == nil) {
sharedGizmoManager = [super allocWithZone:zone]; // original version was: "return [super allocWithZone:zone];"
}
}
return sharedGizmoManager;
}


if not, calls to allocWithZone/alloc BEFORE any call to
+ (MyGizmoClass*)sharedManager
will return different objects...


Pascal Pochet email@hidden ---------------------------------- PGP KeyID: 0x208C5DBF Fingerprint: 9BFB 245C 5BFE 7F1D 64B7 C473 ABB3 4E83 208C 5DBF

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >how to make an object with a single unique instance like NSNull? (From: Johnny Deadman <email@hidden>)
 >Re: how to make an object with a single unique instance like NSNull? (From: Finlay Dobbie <email@hidden>)

  • Prev by Date: Re: How to code a NSString literal with UTF8?
  • Next by Date: Re: How to code a NSString literal with UTF8?
  • Previous by thread: Re: how to make an object with a single unique instance like NSNull?
  • Next by thread: re: how to make an object with a single unique instance like NSNull?
  • Index(es):
    • Date
    • Thread