I’ve a project that is in development and not yet
released so I can adopt new tech without having to worry about existing releases and users. It’s a Core Data app, originally targeted iOS.
I’m writing a macOS target using as much SwiftUI as possible.
I understand - maybe incorrectly - I cannot adopt the new Window in SwiftUI because I must use AppDelegate for my Core Data stack - or do I?
Maybe this is a part of the problem?
I’d like to build a new toolbar for my macOS target that matches the styling of toolbars already used throughout macOS Bog Sur. I’m struggling to figure out how I implement this larger toolbar and add Toolbar items. I’ve watched the talk on What’s New In SwiftUI and attempted to drop some of the toolbar sample code into my project but, while it compiles, the code is ineffective.
any help please?
released so I can adopt new tech without having to worry about existing releases and users. It’s a Core Data app, originally targeted iOS.
I’m writing a macOS target using as much SwiftUI as possible.
I understand - maybe incorrectly - I cannot adopt the new Window in SwiftUI because I must use AppDelegate for my Core Data stack - or do I?
Maybe this is a part of the problem?
I’d like to build a new toolbar for my macOS target that matches the styling of toolbars already used throughout macOS Bog Sur. I’m struggling to figure out how I implement this larger toolbar and add Toolbar items. I’ve watched the talk on What’s New In SwiftUI and attempted to drop some of the toolbar sample code into my project but, while it compiles, the code is ineffective.
any help please?
Hi andrewbuilder,
Although many of Xcode's app templates perform Core Data setup in the App Delegate, it's OK to set up your Core Data stack anywhere you'd like. So, if you want to adopt the new app/scene support in SwiftUI, one option is to set up a NSPersistentContainer in a custom class that you write, and then your SwiftUI App could hold on to an instance of that class in a variable. The SwiftUI Data Essentials session might provide some inspiration on organizing your data and passing it through to your views.
On the other hand, if your app is still using a Storyboard and/or NSWindowController to host your SwiftUI content, you won't be able to set up the toolbar in SwiftUI, but you're free to configure the toolbar directly in AppKit. The 'Adopt the new look of macOS' session outlines some of the AppKit API that you'd use to customize your toolbar for the new design.
Although many of Xcode's app templates perform Core Data setup in the App Delegate, it's OK to set up your Core Data stack anywhere you'd like. So, if you want to adopt the new app/scene support in SwiftUI, one option is to set up a NSPersistentContainer in a custom class that you write, and then your SwiftUI App could hold on to an instance of that class in a variable. The SwiftUI Data Essentials session might provide some inspiration on organizing your data and passing it through to your views.
On the other hand, if your app is still using a Storyboard and/or NSWindowController to host your SwiftUI content, you won't be able to set up the toolbar in SwiftUI, but you're free to configure the toolbar directly in AppKit. The 'Adopt the new look of macOS' session outlines some of the AppKit API that you'd use to customize your toolbar for the new design.