Posts

Post not yet marked as solved
9 Replies
0 Views
Have narrowed down problem. When first run, there is no image, and have user open a local file. I then create and save the bookmark for that, so on subsequent run, can access files based on user having already done so. If I call the function to save bookmark, it saves successfully, but when gets to image view, fails to display the image but program continues to run as if all is well. And on next run it retrieves bookmark and opens file and all works fine. IF I DON'T save bookmark, the program goes on to work and displays image all is well. But on next run of course, fails since there is no bookmark saved. Here is function that saves bookmark: func saveBookmarkForSelectedURL(fileURL: URL?) -> Bool {         print("enter saveBookmarkForSelectedURL (String(describing: fileURL))")         do {             if let selectedURL =  fileURL {                 // Create a security-scoped bookmark                 // "Returns bookmark data for the URL, created with specified options and resource values."                 // Return Value: Type: Data - A bookmark for the URL.                 let bookmarkData = try selectedURL.bookmarkData(options: .withSecurityScope, includingResourceValuesForKeys: nil, relativeTo: nil)                 // get an instance of UserDefaults                 let userDefaults = UserDefaults.standard                 //  store the newly-created bookmark in UserDefaults                 // accessible with a meaningful key; user defaults supports storing                 // and fetching the Data/NSData types                 userDefaults.set(bookmarkData, forKey: "PermanentFileBookmark")                 // creating the bookmark did not throw an error, so return positive                 print("just stored bookmark (bookmarkData)")                 return true             } else {                 print("ERROR: You cannot bookmark a URL that is nil")                 return false             }         } catch let error {             print("Could not create a bookmark because: ", error)             return false  }     } // end func saveBookmarkForSelectedURL()
Post not yet marked as solved
9 Replies
0 Views
I have submitted a stripped down version, ImageTest(101) thru Feedback Assistant, along with a copy of the app and crash report.
Post not yet marked as solved
9 Replies
0 Views
The other symptom is that despite all the prep that is successful, the Image() in contentView fails to open a window and show the image that was opened/loaded. I am in process of stripping app, have a test version that is somewhat smaller called ImageTest with same symptoms.
Post not yet marked as solved
9 Replies
0 Views
Will attach top portion of that file, declarations and init here.
Post not yet marked as solved
9 Replies
0 Views
Yes, using UserDefaults directly and after the saving of persistent url. Yes have @main. Here is the PictureWindowApp.swift: import SwiftUI @main struct PictureWindowApp: App {     @ObservedObject var appState = AppState()          var body: some Scene {         WindowGroup {             ContentView(appState: appState)                 .edgesIgnoringSafeArea(.all)                 .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification), perform: { _ in                     NSApp.mainWindow?.standardWindowButton(.zoomButton)?.isHidden = true                     NSApp.mainWindow?.standardWindowButton(.closeButton)?.isHidden = true                     NSApp.mainWindow?.standardWindowButton(.miniaturizeButton)?.isHidden = true                 })         }         .windowStyle(.hiddenTitleBar)         .windowToolbarStyle(UnifiedCompactWindowToolbarStyle())         .commands {             PictureWindowCommands(appState: appState)         }     } }
Post not yet marked as solved
9 Replies
0 Views
Yep, sandbox entitlements for user selected file and picture folder. There isn't choice of user selected directory.