/CopyLocationToClipboardService/CopyCurrentLocationService.m
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 13int main (int argc, const char * argv[]) 14{ 15 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 16 17 /* 18 * This is basically boiler-plate code for a service-specific application 19 * that does not have an interface (i.e. part of a larger application). 20 * 21 * The key part is to instantiate the provider object (CurrentLocationProvider here), 22 * register the service, then go into the run loop. 23 */ 24 25 CopyCurrentLocationProvider *currentLocationInstance = [[CopyCurrentLocationProvider alloc] init]; 26 NSRegisterServicesProvider(currentLocationInstance, @"CopyCurrentLocationService"); 27 28 /* 29 * Limit the run time to 30 seconds 30 */ 31 [[NSRunLoop currentRunLoop] acceptInputForMode:NSDefaultRunLoopMode 32 beforeDate:[NSDate dateWithTimeIntervalSinceNow:30.0]]; 33 34 /* 35 * And if we're here, we're done with this run of the service 36 */ 37 [currentLocationInstance release]; 38 39 [pool drain]; 40 41 return 0; 42}