Hi,

You should take a look at this article:

http://c2.com/cgi/wiki?SingletonsAreEvil

Cheers
Dave

On 8 Jun 2014, at 17:30, William Squires <wsqui...@satx.rr.com> wrote:

>  Okay, I have several classes in my (somewhat large, and growing) project 
> that implement the singleton pattern via a [<classname> shared<whatever>] 
> class method (and a file-scope static reference) that uses lazy loading to 
> instantiate the singleton the first time a reference is asked for. Is it 
> considered better to put all of these calls in the main() function before any 
> other code executes, or not worry about it, and just access them through the 
> above class methods when and where needed?
>  Also, in C, it's common to throw away the return value from a function (a la 
> printf(), which returns an int, but coders rarely use the return value), but 
> is it good practice to throw away the result of the above method calls 
> (messages) just to silence the compiler?
> 
> i.e.
> 
> -(void)someMethod
> {
> ...
> [MyClass sharedController]; // No warning here.
> ...
> }
> 
> as opposed to:
> 
> -(void)someMethod
> {
> MyClass *p = [MyClass sharedController]; // <- Yellow triangle here for 
> unused variable 'p'
> ...
> }
> 
> TIA! :)
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/dave%40looktowindward.com
> 
> This email sent to d...@looktowindward.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to