Components:
macOS 11.6, iMac (Retina 5K, 27-inch, Late 2014), Xcode: Version 13.0 (13A233) Capabilities: User selected & Download folder files Read/Write Language Swift 5
Small App fragment
========= BEGIN =========
import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate, NSComboBoxDelegate, NSOpenSavePanelDelegate {
let dialog = NSSavePanel()
@IBOutlet var window: NSWindow!
@IBOutlet weak var selectOutFileLabelOutlet: NSTextField!
@IBOutlet weak var selectFileCBOutlet : NSComboBox!
@IBOutlet weak var ouputFileNameOutlet: NSTextField!
@IBOutlet weak var browse4FileOutlet : NSButton!
@IBOutlet weak var progressBarOutlet : NSProgressIndicator!
@IBOutlet weak var convertButtonOutlet: NSButton!
@IBAction func convertButtonClicked(_ sender: Any) {
// STUB
}
@IBAction func browseButtonClicked(_ sender: Any) {
dialog.title = "Choose output file"
dialog.showsResizeIndicator = true
dialog.showsHiddenFiles = true
dialog.canCreateDirectories = true
dialog.allowedFileTypes = [".ear", ".mer", ".ven", ".mar", ".jup", ".sat", ".ura", ".nep", ".plu"]
dialog.allowsOtherFileTypes = true
dialog.treatsFilePackagesAsDirectories = true
let answer = dialog.runModal() // ERROR
if answer == NSApplication.ModalResponse.OK {
let results = dialog.url
// Do whatever you need with every selected file
print ( results!.path )
} else {
print ( "User clicked on 'Cancel'" )
return
}
}
var sourceFileName : String = ""
var targetFileName : String = ""
let resourcePathPrefix : String = "(Bundle.main.resourcePath!)/VSOP87-Files/"
var outputFilePath : String = ""
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
dialog.delegate = self
selectFileCBOutlet.delegate = self
setupComboBox()
}
}
====================
When the action: browseButtonClicked(_ sender: Any) is called all the properties of the "dialog" are set then after quite a wait (4 seconds or so) the following error is issued:
=== ERROR ==========
`2021-10-03 15:24:17.110702-0700 ConvertVSOPToDataFile[4887:105883] -[NSSavePanel beginServicePanel]_block_invoke : Could not advance an Open/Save panel to run phase due to error: Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}
2021-10-03 15:24:17.114075-0700 ConvertVSOPToDataFile[4887:105883] -[NSSavePanel beginServicePanel] : an exception occurred during attempt to advance an Open/Save panel to run phase!
2021-10-03 15:24:17.116188-0700 ConvertVSOPToDataFile[4887:105883] -[NSSavePanel runModal] caught non-fatal NSObjectNotAvailableException 'The operation couldn’t be completed. (com.apple.ViewBridge error 16.)' with user dictionary {
error = "Error Domain=com.apple.ViewBridge Code=16 "(null)" UserInfo={com.apple.ViewBridge.error.hint=advance to run phase, com.apple.ViewBridge.error.description=NSViewBridgeInvalidError}";
} and backtrace (
0 CoreFoundation 0x00007fff205601db __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20299d92 objc_exception_throw + 48
2 AppKit 0x00007fff237148ab -[NSSavePanel beginServicePanel] + 717
3 AppKit 0x00007fff23715044 -[NSSavePanel runModal] + 98
4 ConvertVSOPToDataFile 0x000000010334cea1 $s21ConvertVSOPToDataFile11AppDelegateC19browseButtonClickedyyypF + 1313
5 ConvertVSOPToDataFile 0x000000010334d681 $s21ConvertVSOPToDataFile11AppDelegateC19browseButtonClickedyyypFTo + 65
6 AppKit 0x00007fff22f0e2bb -[NSApplication(NSResponder) sendAction:to:from:] + 288
7 AppKit 0x00007fff22f0e15f -[NSControl sendAction:to:] + 86
8 AppKit 0x00007fff22f0e091 __26-[NSCell _sendActionFrom:]_block_invoke + 131
9 AppKit 0x00007fff22f0df98 -[NSCell _sendActionFrom:] + 171
10 AppKit 0x00007fff22f0dede -[NSButtonCell _sendActionFrom:] + 96
11 AppKit 0x00007fff22f0afc7 NSControlTrackMouse + 1820
12 AppKit 0x00007fff22f0a883 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 130
13 AppKit 0x00007fff22f0a74a -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 697
14 AppKit 0x00007fff22f09a72 -[NSControl mouseDown:] + 722
15 AppKit 0x00007fff22f07e5e -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 4961
16 AppKit 0x00007fff22e77648 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2594
17 AppKit 0x00007fff22e76a06 -[NSWindow(NSEventRouting) sendEvent:] + 347
18 AppKit 0x00007fff22e74e14 -[NSApplication(NSEvent) sendEvent:] + 352
19 AppKit 0x00007fff2314dbe1 -[NSApplication _handleEvent:] + 65
20 AppKit 0x00007fff22cddc8e -[NSApplication run] + 623
21 AppKit 0x00007fff22cb1e6c NSApplicationMain + 816
22 ConvertVSOPToDataFile 0x0000000103350064 $sSo21NSApplicationDelegateP6AppKitE4mainyyFZ + 36
23 ConvertVSOPToDataFile 0x0000000103350037 $s21ConvertVSOPToDataFile11AppDelegateC5$mainyyFZ + 39
24 ConvertVSOPToDataFile 0x0000000103350208 main + 24
25 libdyld.dylib 0x00007fff20409f3d start + 1
26 ??? 0x0000000000000003 0x0 + 3
)
==============` END =============
Failure is consistent as is the error output.
Any ideas would be appreciated!
TIA
ClarkW