Post

Replies

Boosts

Views

Activity

How does one create a DataStoreSnapshot for a custom data store ?
The WWDC2024 custom data store example doesn't provide any details on how one would go about creating a DataStoreSnapshot. The example uses a DefaultSnapshot for persisting the data in the DefaultSnapshot format directly in the JSON file. There appears to be no documentation or examples of how one might create a DataStoreSnapshot from data from another database. The Apple documentation for DefaultSnapshot provides no examples of how one might create such a snapshot from data retrieved elsewhere. Can anyone provide a simple example of how one might create such a snapshot from a remote database such that it can be returned as part of the response to a fetch request. For the purpose of this example let's assume I have a CSV file with rows of data and code to read the data from this file. How would I create a snapshot or snapshots for each of the rows of data.
1
0
808
Oct ’24
Example of creating NSView with custom bindings
Does anyone know where I can find an example of creating a NSView subclass with custom bindings. I need to be able to bind to the object in interface builder. This is the only reference in Apple documents but as is often the case there appear to be no examples. https://developer.apple.com/documentation/objectivec/nsobject/nskeyvaluebindingcreation
0
0
198
Oct ’24
Help creating notarised DMG for macOS app distribution
I am trying to follow the guide for automating creation of a DMG for distribution of a macOS application but can't figure out how to get the ExportOptions.plist from a manual export. I am trying to follow this guide: https://developer.apple.com/documentation/security/customizing-the-xcode-archive-process What is a 'manual export' and what are the steps for creating a manual export. `# Ask xcodebuild(1) to export the app. Use the export options # from a previous manual export that used a Developer ID. /usr/bin/xcodebuild -exportArchive -archivePath "$ARCHIVE_PATH" -exportOptionsPlist "$SRCROOT/ExportOptions.plist" -exportPath "$EXPORT_PATH"` Where is "$SRCROOT" ? presumably I have to copy this ExportOptions.plist to this location. Thanks - I am sure this must be blindingly obvious because there seems to be no reference as to how you do this 'manual export' or where one finds the resulting options file.
1
0
196
Mar ’25
Swift Task.init{ NSAlert.runModal } crashes !
Why is NSAlert.runModal() crashing when called from within the Task.init { } block ? Is this a bug. I can upload a sample program if required.     @IBAction func start(_ sender: Any) {                  isBusy = true         log("start")                           Task.init {                          log("sync start")             let (result, message) = await asyncObj.process(5, progress: progressCallback)             isBusy = false             log(message)             log("sync end")  // Reports as running in main thread                                       // CRASHES HERE !             alert = self.dialogOK(question: "Some question", text: "Some thing else")                          log("task end") // Reports as running in main thread         }              }          func dialogOK(question: String, text: String) -> NSAlert {         let alert = NSAlert()         alert.messageText = question         alert.informativeText = text         alert.alertStyle = .warning         alert.addButton(withTitle: "OK")         return alert //.runModal() == .alertFirstButtonReturn     }     /// This process MUST run on a background thread - it cannot run on the main thread     /// So how do I force it to run on a background thread ?     func process(_ count: Int, progress: @escaping (Double)->Void) async -> (Bool, String)  {                  // Still on the main thread here ??         log("1 First part on the main thread ??")                  let task = Task.detached { () -> (Bool, String) in                          //Thread.sleep(forTimeInterval: 0.1)             log("2 Run a loop in the background")             log("  Thread: \(Thread.isMainThread ? "UI" : "BG")")                          var cnt = 0             for i in 0..<count {                 Thread.sleep(forTimeInterval: 0.025)// sleep(seconds: 0.1)                 log("  i: \(i)")                 cnt += 1                 progress (Double(cnt)/Double(count)*100)                              }             log("  >>>>")                          return (true, "Background task Done")                      }                  let result = await task.value                  log("2 First part on the main thread ??")         return result              }
0
0
939
Dec ’21