Comment on NSThread
Comment on NSThread
- Subject: Comment on NSThread
- From: Kirk Kerekes <email@hidden>
- Date: Tue, 16 Jul 2002 10:44:19 -0500
Somewhere in Hillegass's _Cocoa_Programming_for_Mac_OS_X_, Aaron makes the
comment that most uses of NSThread can be better handled with creative use
of NSTimer.
Sage advice indeed. I wish I had listened more carefully.
If the inability to actually release an NSTimer bugs you (as I know it bugs
me), consider going a step lower to NSObject's
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:
(NSTimeInterval)delay
and
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:
(NSTimeInterval)delay inModes:(NSArray *)modes
-- which I infer contain NSTimer's core functionality.
I ripped a bunch of crash-prone threads out of my current app and replaced
them with NSTimer and performSelector techniques, and the perceived speed
of the app increased dramatically. Add some judicious use of
NSNotifications to handle document closing and application quitting, and
the solution was complete.
It never crashes inexplicably, and I don't have to worry about "thread safe"
considerations.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.