У меня есть этот Objective-C Код:
- (IBAction)selectFileButtonAction:(id)sender {
//create open panel...
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
// NSLog(@"Open Panel");
//set restrictions / allowances...
[openPanel setAllowsMultipleSelection: NO];
[openPanel setCanChooseDirectories:NO];
[openPanel setCanCreateDirectories:NO];
[openPanel setCanChooseFiles:YES];
//only allow images...
[openPanel setAllowedFileTypes:[NSImage imageFileTypes]];
//open panel as sheet on main window...
[openPanel beginWithCompletionHandler:^(NSInteger result) {
if (result == NSFileHandlingPanelOKButton) {
//get url (should only be one due to restrictions)...
for( NSURL* URL in [openPanel URLs] ) {
// self.roundClockView1.URL = URL ;
_thePath = URL;
currentSelectedFileName = [[URL path] lastPathComponent];
// [_roundClockView1 setNeedsDisplay:1];
[self openEditor];
}
}
}];
Теперь я хочу написать это одно и то же в быстром. Вот что я сделал до сих пор:
@IBAction func selectAnImageFromFile(sender: AnyObject) {
var openPanel = NSOpenPanel()
openPanel.allowsMultipleSelection = false
openPanel.canChooseDirectories = false
openPanel.canCreateDirectories = false
openPanel.canChooseFiles = true
openPanel.beginWithCompletionHandler(handler: (Int) -> Void)
}
и здесь я застрял. Спасибо за помощь.