/CopyLocationToClipboardService/CopyCurrentLocationService.m

http://osxsystemservices.googlecode.com/ · Objective C · 42 lines · 13 code · 7 blank · 22 comment · 0 complexity · c5539f49b444776dad7e989b8bcad34b MD5 · raw file

  1. /*
  2. * CopyLocationToClipboardService
  3. *
  4. * Created by Ron Olson on 9/6/10.
  5. * Copyright 2010 Ron Olson. All rights reserved.
  6. *
  7. * You are free to use this code any way you want.
  8. * Hopefully it will help you in whatever you're doing.
  9. */
  10. #import <Foundation/Foundation.h>
  11. #import "CopyCurrentLocationProvider.h"
  12. int main (int argc, const char * argv[])
  13. {
  14. NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  15. /*
  16. * This is basically boiler-plate code for a service-specific application
  17. * that does not have an interface (i.e. part of a larger application).
  18. *
  19. * The key part is to instantiate the provider object (CurrentLocationProvider here),
  20. * register the service, then go into the run loop.
  21. */
  22. CopyCurrentLocationProvider *currentLocationInstance = [[CopyCurrentLocationProvider alloc] init];
  23. NSRegisterServicesProvider(currentLocationInstance, @"CopyCurrentLocationService");
  24. /*
  25. * Limit the run time to 30 seconds
  26. */
  27. [[NSRunLoop currentRunLoop] acceptInputForMode:NSDefaultRunLoopMode
  28. beforeDate:[NSDate dateWithTimeIntervalSinceNow:30.0]];
  29. /*
  30. * And if we're here, we're done with this run of the service
  31. */
  32. [currentLocationInstance release];
  33. [pool drain];
  34. return 0;
  35. }