• 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: Is Apple's singleton sample code correct?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is Apple's singleton sample code correct?


  • Subject: Re: Is Apple's singleton sample code correct?
  • From: Greg Titus <email@hidden>
  • Date: Thu, 1 Dec 2005 19:50:29 -0800


On Dec 1, 2005, at 7:02 PM, Shaun Wexler wrote:

@interface MortalSingleton : NSObject
@end

+ (id)new
{
return [self sharedInstance];
}

+ (id)allocWithZone:(NSZone *)zone
{
return [self sharedInstance];
}

+ (id)alloc
{
return [self sharedInstance];
}

- (id)copy
{
return self;
}

- (id)copyWithZone:(NSZone *)zone
{
return self;
}

- (id)mutableCopy
{
return self;
}

- (id)mutableCopyWithZone:(NSZone *)zone
{
return self;
}

Hey Shaun,

You are breaking the retain/release rules here. All these methods should do a retain before returning.

-- Greg
_______________________________________________
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
  • Follow-Ups:
    • Re: Is Apple's singleton sample code correct?
      • From: Shaun Wexler <email@hidden>
References: 
 >Re: Is Apple's singleton sample code correct? (From: David Gimeno Gost <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: mmalcolm crawford <email@hidden>)
 >Re: Is Apple's singleton sample code correct? (From: Shaun Wexler <email@hidden>)

  • Prev by Date: Re: Is Apple's singleton sample code correct?
  • Next by Date: Re: Help on subclassing
  • Previous by thread: Re: Is Apple's singleton sample code correct?
  • Next by thread: Re: Is Apple's singleton sample code correct?
  • Index(es):
    • Date
    • Thread