1. I added Sudden Termination to my app. I have a controller that watches a 
WebHistory instance for changes and the dirty flag is KVO-compliant. When the 
flag goes from non-dirty to dirty, my application delegate suspends Sudden 
Termination and calls the save-history method after a 60-second delay (with 
-performSelector: withObject: delay:, not an NSTimer). When the flag goes from 
dirty to non-dirty, my application delegate resumes Sudden Termination. (Note 
that any additional dirtying events that happen within a minute-delay period 
are incorporated with the save for the initiating dirtying.) Is this implicit 
balancing between suspend and resume OK?

I do not protect the function that saves the WebHistory store to disk, nor the 
export-data target-action; that’s supposedly OK since both of those are 
contained in a single function (each), which are called during the main thread.

2. I’m still trying to grok (user-interface) Resume, so I can get Automatic 
Termination going. Cocoa takes care of some of the work saving each window and 
its data (to some special Resume store), but I have to create overrides for my 
window and/or delegate and/or controller to save any associated data I defined 
(via NSCoder calls that the Cocoa’s Resume code uses). Right now, my controller 
class has a single -init method that starts up the window’s XIB. But it seems 
that the Resume code creates windows first, so I have to add alternate 
controller initializers that take in an existing window, right?

Cocoa’s Resume code takes care of any suspensions with Sudden Termination, I 
guess.

The explanation for Resume was per-window, but I have global state I need to 
add to Resume too. How? I load/save the WebHistory at app launch/quit, but I 
have a user default that controls it. Since Resume is supposed to get you back 
where you left off, I think I should save WebHistory in the Resume store even 
when the regular load/save preference is set to not save/load. (A Resume-based 
WebHistory still won’t get saved to the permanent History file.) Am I wrong 
here?

3. How do you test/debug Sudden and/or Automatic Termination, besides hoping 
the system triggers them? I got Sudden Termination by adding NSLog to the 
will-terminate notification. The log did not print only if I quit my app 
immediately after starting and without loading a web page. Quitting within a 
minute of loading a web page did print the log. But waiting after a minute 
(with another log message) still had the log for a normal quit. I think that 
although my code resumed Sudden Termination, NSUserDefaults probably didn’t due 
to caching.

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to