Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: self and _cmd



On Wednesday, September 5, 2001, at 05:36 AM, Ondra Cada wrote:
Rob Rix (RR) wrote at Wed, 5 Sep 2001 02:17:15 -0400:
RR> Just recalling how the runtime sends implicit arguments to methods: self
RR> and _cmd. Well, we all know how useful self is, but has anybody done
RR> anything useful/cool with _cmd?

-(void)notWorthUsingNSTimer {
...
[self performSelector:_cmd withObject:nil afterDelay:delay];
}

Ha! the implementation will show you what's not worthwhile. :-)

-performSelector:withObject:afterDelay: simply creates an NSTimer and schedules it. Or CFRunLoopTimer, I forget which nowdays, but it's the same thing.


The odd thing about this example is that you're scheduling "notWorthUsingNSTimer" to execute later, which is probably not what you want, since it'll apparently result in an infinite, if slowly, and "out-of-bandedly", executed, loop. :-)


Chris Kane
Cocoa Frameworks, Apple




Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.