/thirdparty/SPMediaKeyTap/SPInvocationGrabbing/main.m

http://github.com/tomahawk-player/tomahawk · Objective C · 38 lines · 35 code · 3 blank · 0 comment · 0 complexity · 64cedb4901f14b8f82160d41834812c7 MD5 · raw file

  1. #import <Cocoa/Cocoa.h>
  2. #import "NSObject+SPInvocationGrabbing.h"
  3. @interface Foo : NSObject {
  4. int a;
  5. }
  6. -(void)startIt;
  7. -(void)theBackgroundStuff;
  8. -(void)theForegroundStuff;
  9. @end
  10. @implementation Foo
  11. -(void)startIt;
  12. {
  13. NSLog(@"Starting out on the main thread...");
  14. a = 3;
  15. [[self inBackground] theBackgroundStuff];
  16. }
  17. -(void)theBackgroundStuff;
  18. {
  19. NSLog(@"Woah, this is a background thread!");
  20. a += 6;
  21. [[self onMainAsync:YES] theForegroundStuff];
  22. }
  23. -(void)theForegroundStuff;
  24. {
  25. NSLog(@"Hey presto: %d", a);
  26. }
  27. @end
  28. int main() {
  29. NSAutoreleasePool *pool = [NSAutoreleasePool new];
  30. Foo *foo = [Foo new];
  31. [foo startIt];
  32. [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
  33. [pool release];
  34. return 0;
  35. }