• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Comment on NSThread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Comment on NSThread
      • From: Nathan Day <email@hidden>
  • Prev by Date: Re: Framework library...
  • Next by Date: Re: Framework library...
  • Previous by thread: Re: Framework library...
  • Next by thread: Re: Comment on NSThread
  • Index(es):
    • Date
    • Thread