Skip to content

Instantly share code, notes, and snippets.

@atr000
Created October 29, 2010 23:01
Show Gist options
  • Save atr000/654624 to your computer and use it in GitHub Desktop.
Save atr000/654624 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
int main(int argc, const char* argv[])
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSAppleScript* script = [[NSAppleScript alloc] initWithSource:@"tell application \"Finder\"\nclean up window of desktop\nend tell"];
while ( true )
{
NSAutoreleasePool* pool2 = [[NSAutoreleasePool alloc] init];
[script executeAndReturnError:nil];
sleep(30);
[pool2 release];
}
[pool drain];
return 0;
}
@unixpickle
Copy link

Interesting to see. I might suggest using [[NSThread currentThread] sleepForTimeInterval:] instead of sleep() since it is native to cocoa. Other than that, completely perfect.

@newacct
Copy link

newacct commented Mar 10, 2011

@unixpickle: [[NSThread currentThread] sleepForTimeInterval:] is incorrect because sleepForTimeInterval: is a class method. You mean [NSThread sleepForTimeInterval:] instead.

@unixpickle
Copy link

Ah yes you got my on that one. Generally when I am using Xcode, code highlighting is a quick way of telling of something is declared, but obviously we don't have that here :-P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment