Re: Main window disappears. Sometimes.
Re: Main window disappears. Sometimes.
- Subject: Re: Main window disappears. Sometimes.
- From: Paul Sargent <email@hidden>
- Date: Mon, 2 Jun 2008 10:50:34 +0100
El 02/06/2008, a las 10:45, Michael Vannorsdel escribió:
This will happen if the window is deallocated. It's probably
getting cleaned up by garbage collection.
On 2 Jun 2008, at 10:05, Francis Perea wrote:
I've also supposed it was happening that, and I've tried to correct
it by using retain in each one of init methods of both classes, but
no results.
What I mean is, in every init method, when I call the [super init]
I've tried [[super init] retain]. But no way.
As Michael says, retain and release become null-operations when
garbage collection is switched on (so code can be written to run as
both GC and non-GC).
If nothing is holding onto a pointer to your window then it'll be
collected by the garbage collector. Something has to hold on to a
pointer to it.
I believe it's worth writing an application or two without using
garbage collection if you're starting out. GC is one area in Cocoa
that's a bit like magic if you don't understand how it works. Learning
everything else with 'magic stuff' happening can be difficult. Retain
and Release are pretty simple, and as long as you stay within
Objective C (i.e. don't start using the CoreFoundation C API) managing
it all is pretty straight forward.
Once you're comfortable with that, switch GC back on and get used to
how it works._______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden