Re: static objects "autoreleased with no pool in place - just leaking"
Re: static objects "autoreleased with no pool in place - just leaking"
- Subject: Re: static objects "autoreleased with no pool in place - just leaking"
- From: j o a r <email@hidden>
- Date: Fri, 13 Feb 2004 09:45:31 +0100
On 2004-02-13, at 09.31, m wrote:
>
This is the kind of thing that I did all the time in C++, it's hard to
>
believe that no one has figures out a clean way to do it in Obj-C++.
Just because you *had* to do something "all the time" in C++ doesn't
mean that you *need* to do it in Cocoa/ObjC, nor necessarily that you
should. When you learn something new, prepare to have to learn new
things.
Global variables might be "handy", but are frowned upon for several
reasons. Cocoa and Objective-C are used for OOP primarily. In an OO
context you would not have things like this dangling around, but would
instead associate them with a class. Usually you would create
convenience methods for them like this:
@interface NSColor (MyColorAdditions)
+ (NSColor *) blackColor;
+ (NSColor *) redColor;
// ...etc.
@end
(Note that most of the colors that you claim to need to add as static
variables can already be obtained via convenience methods from NSColor.
They are also singleton instances, and can be compared via the "=="
operator if you so wish - or using "isEqual:" if you are more into OOP)
@interface NSCursor (MyCursorAdditions)
+ (NSCursor *) busyCursor;
+ (NSCursor *) handCursor;
@end
(Note that there is an "openHandCursor" available in NSCursor on Mac OS
X 10.3, and usually you let the system manage the busy cursor)
j o a r
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.