discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: patch for NSApplication.m


From: David Relson
Subject: RE: patch for NSApplication.m
Date: Wed, 24 Jul 2002 16:04:49 -0400

At 03:46 PM 7/24/02, David Ayers wrote:
Hello David,

>
> However, it bothers me to see an object assigned to global variable NSApp
> before the object is initialized.  Changing the code slightly would
> initialize the object before it's assigned.
>
> Also, to be consistent with the singleton pattern, method -[NSApplication
> init] should _not_ assign a value to NSApp.  All usages of NSApp in this
> method should be changed.

I'm sure some one "official" will review your patch and give his two cents,
but I believe the point was to make sure that anyone trying to create a new
instance by using [[NSApplication alloc] init] or [NSApplication new] or
whatever will always get the singelton. The current implementation enforces
it. With your patch, someone could create NSApplication-Objects before
sharedApplication is called and there would be multiple NSApplication
objects. The way it is now, this can't happen. Or am I missing something
here?

Cheers,
Dave

Dave,

That makes sense, though I think having two assignments to NSApp is wrong. If the assignment is to be in -init, then +sharedApplication only needs call [[self alloc] init] and doesn't need to assign the value to NSApp.

David




reply via email to

[Prev in Thread] Current Thread [Next in Thread]