Re: Is Apple's singleton sample code correct?
Re: Is Apple's singleton sample code correct?
- Subject: Re: Is Apple's singleton sample code correct?
- From: glenn andreas <email@hidden>
- Date: Thu, 1 Dec 2005 23:09:38 -0600
On Dec 1, 2005, at 10:41 PM, Jeff Laing wrote:
What I was saying was that *I* dont understand why you'd *copy* a real
singleton, ie one of those objects of the class for which there
should only
ever be one instance.
Consider the statement:
[myDictionary setObject: @"Null value" forKey: [NSNull null]];
[NSNull null] is a singleton, which is also an NSValue, and NSValue
supports the NSCopying protocol, and dictionaries copy their keys to
make sure that they aren't mutated out from under them..
A quick search also turns up:
@interface WebUndefined : NSObject <NSCoding, NSCopying>
+ (WebUndefined *)undefined;
So there aren't a lot of them, but they are used more often than
suspected...
Glenn Andreas email@hidden
<
http://www.gandreas.com/> wicked fun!
Widgetarium | the quickest path to widgets
_______________________________________________
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