Re: How to use NSTimer correctly?
Re: How to use NSTimer correctly?
- Subject: Re: How to use NSTimer correctly?
- From: "Adam R. Maxwell" <email@hidden>
- Date: Sat, 25 Jul 2009 10:22:14 -0700
On Jul 25, 2009, at 10:04 AM, Alexander Bokovikov wrote:
On 25.07.2009, at 21:29, Adam R. Maxwell wrote:
Your original post said you're trying to do this at quit, but you
can't rely on any object being sent -dealloc at application quit
time. Do your cleanup in applicationWillTerminate:, either as the
app delegate or by registering for the notification. You
definitely don't want to use [self release].
Probably I've found the reason. The "Release when closed" flag was
set in the Window properties. Therefore my NSTableView has been
released as soon as I clicked window close button, but other
application parts like AppController still were active and timer
still generated its events.
As far as I understand now, this flag "Release when closed" may be
set only for a window without any interaction, like a message
window, etc. I's not correctly to set this flag, when there are some
objects, referring to the closed window content. This is just my case.
"Release When Closed" is covered here:
http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmNibObjects.html
Also, check the API doc for -[NSWindow setReleasedWhenClosed:]. There
are some subtleties associated with it, and I personally think it's a
nuisance.
Another question arrives - who will release this window and when it
will be released? My AppController is set as NSApp delegate, and it
responds to "applicationShouldTerminateAfterLastWindowClosed"
message "YES". Does it mean that NSApp will release this my window?
Why are you worrying about this? As I said previously, if your
application is quitting, dealloc may not be called. Just fulfill your
part of the memory contract, and release the window if you own it.
Also I see windowWillClose message in the API reference. It's
described : "Sent by the default notification center". What does it
mean? What is this default notification center and how to get this
message?
http://lmgtfy.com/?q=default+notification+center
Try the second URL.
Should I set my AppController, as the window delegate to receive it?
Probably. Try it and see what happens.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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