eliminate all warnings by switching NSOpenPanel/NSSavePanels to use completion handler blocks

This commit is contained in:
Mitchell Livingston
2011-12-11 22:31:01 +00:00
parent d524deecb0
commit 30f7fae5a5
8 changed files with 176 additions and 246 deletions

View File

@@ -194,10 +194,25 @@
[panel setCanChooseFiles: NO];
[panel setCanChooseDirectories: YES];
[panel setCanCreateDirectories: YES];
[panel beginSheetForDirectory: nil file: nil types: nil
modalForWindow: [fCustomLocationPopUp window] modalDelegate: self didEndSelector:
@selector(customDownloadLocationSheetClosed:returnCode:contextInfo:) contextInfo: nil];
[panel beginSheetModalForWindow: [fCustomLocationPopUp window] completionHandler: ^(NSInteger result) {
const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
if (result == NSFileHandlingPanelOKButton)
{
NSString * path = [[[panel URLs] objectAtIndex: 0] path];
[[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
[[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
}
else
{
if (![[GroupsController groups] customDownloadLocationForIndex: index])
[[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
}
[self refreshCustomLocationWithSingleGroup];
[fCustomLocationPopUp selectItemAtIndex: 0];
}];
}
- (IBAction) toggleUseCustomDownloadLocation: (id) sender
@@ -216,26 +231,6 @@
[fCustomLocationPopUp setEnabled: ([fCustomLocationEnableCheck state] == NSOnState)];
}
- (void) customDownloadLocationSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
{
NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
if (code == NSOKButton)
{
NSString * path = [[[openPanel URLs] objectAtIndex: 0] path];
[[GroupsController groups] setCustomDownloadLocation: path forIndex: index];
[[GroupsController groups] setUsesCustomDownloadLocation: YES forIndex: index];
}
else
{
if (![[GroupsController groups] customDownloadLocationForIndex: index])
[[GroupsController groups] setUsesCustomDownloadLocation: NO forIndex: index];
}
[self refreshCustomLocationWithSingleGroup];
[fCustomLocationPopUp selectItemAtIndex: 0];
}
#pragma mark -
#pragma mark Rule editor