Post

Replies

Boosts

Views

Activity

Failing to insert @Model class into managed object context
Greetings. I'm trying to insert objects into the managed context but I'm getting a runtime error "Thread 1: Cannot insert 'MyClass' in this managed object context because it is not found in the associated managed object model.". The code to set things up is pretty much straight from Apple - var sharedModelContainer: ModelContainer = { let schema = Schema([ MyClass.self, MyOtherClass.self ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { return try ModelContainer(for: schema, configurations: [modelConfiguration]) } catch { fatalError("Could not create ModelContainer: \(error)") } }() The context is being accessed through the environment like so - public final class MyAppLogic { @Environment(\.modelContext) private var context ... ... myClasses.forEach { myClass in context.insert(myClass) } Any suggestions greatly appreciated.
4
2
1.8k
Sep ’23
SwiftData: Accessing a context outside of a view not possible.
Getting a warning from the Xcode compiler about accessing a context outside of a view. It popped up in white text on a purple background, not the usual white on yellow warning color. The actual warning text is: Accessing Environment's value outside of being installed on a View. This will always read the default value and will not update. This seems to mean that any datastore access must be done within a view, and isn't possible from the model or some sort of DataManager class. Am I reading this correctly? I'm trying to keep the business logic out of the views. I can do it with everything except the datastore code because of this context issue. Doesn't seem to make sense. Suggestions greatly appreciated.
4
2
4.7k
Sep ’23
USB driver for MIDI keyboard
Greetings. I'm trying to build an Apple Silicon driver for a Roland keyboard which is no longer supported by the manufacturer. The most recent official driver is from 2010. From my limited understanding of the Apple documentation, it seems to be telling me that I need to build a codeless dext which overrides some sort of base class. The keyboard uses bog standard USB 1.0 to communicate with the host. Total newb in the driver area so if anyone could point me in the right direction on where to start I would be totally grateful.
0
0
722
Mar ’24
Suggestions on macOS and iPad app structure
Building an app to edit the various parameters of digital musical instruments. A typical user would have perhaps max 6 instruments, out of the hundreds of possibilities. Would like to structure the app with a global window, menu, etc which would be a free download. The user could download editor inserts for their particular set of instruments and ignore all of the others. The downloaded editors would show as options in a menu. It seem like more than a widget but less than a library. Building a monolithic app containing all possible editors doesn't seem like an option, but separate full-app editors for each piece of gear doesn't sound right either. Any suggestions out there? Thanks very much Brian
0
0
95
May ’25