Skip to content

Instantly share code, notes, and snippets.

@vade
Created September 25, 2011 04:34
Show Gist options
  • Save vade/1240236 to your computer and use it in GitHub Desktop.
Save vade/1240236 to your computer and use it in GitHub Desktop.
double max = [URLs count];
[importProgress setMaxValue:max];
[NSApp beginSheet:importSheet
modalForWindow:libraryWindow
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for(NSURL* aURL in URLs)
{
if(self.cancelImport)
{
self.cancelImport = NO;
break;
}
NSString* aPath = [aURL path];
[aPath retain];
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self.database addGamesFromPath:aPath toCollection:nil searchSubfolders:YES];
});
[importCurrentItem setStringValue:[[aPath lastPathComponent] stringByDeletingPathExtension]];
[importProgress incrementBy:1.0];
[importSheet display];
[aPath release];
}
[NSApp endSheet:importSheet];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment