2009年10月27日 星期二

在NSTimer event內 用 abortModal 來停止 runModalForWindow

http://www.omnigroup.com/mailman/archive/macosx-dev/2004-January/050089.html

Are you calling stopModal from an IBAction method?

Quote from the NSApplication docs:

- (void)stopModal

Stops a modal event loop. This method should always be paired with a
previous invocation of runModalForWindow: or
beginModalSessionForWindow:. When runModalForWindow: is stopped with
this method, it returns NSRunStoppedResponse. This method stops the
loop only if it's executed by code responding to an event. If you need
to stop a runModalForWindow: loop outside of one of its event callbacks
(for example, a method repeatedly invoked by an NSTimer object or a
method running in a different thread), use the abortModal method.
(end quote)

So, it looks to me like you must invoke stopModal only in an IBAction.
Of course, if you're not, then this won't help, but it's all I could
come up with. Hope you get your problem sorted out.

David

沒有留言: