Post

Replies

Boosts

Views

Activity

Xcode 26 Issue with functional of bridging header in Xcode project with both objective-c and swift
I'm in the process of add some swift code that is all objective-c. I have trouble with my actual app so I have worked on a prototype. There is what I have done Created a new Xcode project, selecting App and Objc Added a blank Swift file and accepted the generation of the -Bridging-Header. In project build setting, Yes for Defines Modules, Yes for Always Embed Swift Libraries Add appropriate .h file to Bridging header In Build Settings, in Swift Compiler - General, Bridging Header has correct path to the bridging header file Setup the single swift file in this was using @objc like this: @objcmembers class MySwiftClass: NSObject { func myMethod() { let output = ... } } When the project runs I execute in the objc ViewController: MySwiftClass *swiftObject = [[MySwiftClass alloc] init]; and get Use of undeclared identifier 'MySwiftClass'
Topic: Design SubTopic: General
0
1
337
Oct ’25
Trouble navigation from detail view to grid view (root view) in app using SwiftData
I am writing an Library app that shows a grid. Each grid location shows the book cover and some info about the book. If the user clicks on a cover, the detail view opens. One option that the user has is a delete the book button. This button deletes the book from SwiftData, but the detail page remains populated. The simple way I want to handle this is to have the delete button also return to the grid view (eg root). Here is the relative code from the CurrentView @State private var path = [Book]() var body: some View { NavigationStack(path: $path) { BookListView(sort: sortOrder, searchString: searchText) .navigationTitle("Library") .navigationDestination(for: Book.self, destination: EditBookView.init) .searchable(text: $searchText) Here is the code from the Grid View var body: some View { LazyVGrid (columns: gridLayout) { ForEach(books) { book in NavigationLink(value: book) { GridRow { VStack { Here is the code from the Detail View var body: some View { Form { VStack (spacing: 0){ BookImageView(book: book) } TextField("Title", text: $book.title) Button("Go Back to ListView", action: { // Action to perform }) } .navigationTitle("Edit Book") .navigationBarTitleDisplayMode(.inline) } // Form } // some View Can you provide the code for the button "Go Back to Last View"
Topic: UI Frameworks SubTopic: SwiftUI
0
0
283
Jun ’24