One Quickie


NSTimers and NSTerminateLater (NSTimer->General)
If your application has an open TCP connection to a server and you receive an applicationShouldTerminate: message, you're likely to want to returnNSTerminateLater so that you can first gracefully shut down the connection before quitting.

There is a gotcha: returning NSTerminateLater stops the main runloop, so your NSTimers will stop working from that point on. Thus, if you were depending on a timer firing to finish up your shut-down process, you'll never see it, and you'll hang. The solution is to return NSTerminateCancel, then do whatever you need to do and then terminate yourself manually. (Thanks to Larry Gerndt for this one!)



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com