Post

Replies

Boosts

Views

Activity

Widget error integrate it with CloudKit
A few months back, I launched an app that operated solely on a local level. Recently, I've begun the process of integrating it with CloudKit, and so far, the model integration has been successful. I've utilized SwiftData for this task, making it relatively straightforward to adjust the models, as shown below: ` @Relationship(deleteRule: .cascade, inverse: \ItemForCategory.category) var itemForCategory : [ItemForCategory]? = [ItemForCategory]() ` In my initial version of the code, the widget functioned perfectly. However, I've encountered an error recently stating Missing return in instance method expected to return 'ItemForCategory?'. @MainActor private func getLastItem () -> ItemForCategory? { guard let modelContainer = try? ModelContainer(for: Category.self) else { return nil } let descriptor = FetchDescriptor<Category>() let appCategories = try? modelContainer.mainContext.fetch(descriptor) let lastItem = appCategories?.compactMap { $0.itemForCategory }.last return lastItem } The error surfaces at the return line of code. I'm hopeful that someone can assist me in resolving this issue. Thank you very much.
0
0
298
Apr ’24
Adopting SwiftData for a Core Data app - Error?
Hello everyone! I'm trying to run this project by Apple, but it doesn't let me, I'm trying to learn more about to swiftData... https://developer.apple.com/documentation/coredata/adopting_swiftdata_for_a_core_data_app On the code it says next: `@MainActor #Preview { AddBucketListItemView(trip: .preview) .modelContainer(PreviewSampleData.container) } But it show me next error, Type 'Trip' has no member 'preview' anybody knows how can I solved, thank you.
0
0
776
Jun ’23
Error using ContexMEnu
Hello Dev's around the world. I'm new using the contextMenu, and I create a card when you tap send you to a view that if you see the code it works with navigationView but if I do a long press using contextMenu it supposed that send me to another view, but I'm using the next code and it doesn't works, it's like a took another card and show me the information of other card. I hope that you can help me, I tried with .sheet and it doesn't work either. ForEach($list) { $Category in NavigationLink(destination: CategoryList(list: $Category)){ CategoryCard(list: Category) .frame(height: 100) .contextMenu{ Button { selectedEditCategory = Category isPreseingDetailEditCardView.toggle() print(Category.title) } label: { Text("Edit") } } } .background( NavigationLink( destination: DetailCardView(list: $Category), isActive: $isPreseingDetailEditCardView, label: { EmptyView() } ) ) } Thank you.
0
0
965
May ’23
SwiftUI encountered an issue when pushing a NavigationLink. Please file a bug.
Hello Team of Devs, I'm trying to use a card with to actions, the first action is when I press it show me a list (it works) and the second action it's when I made a long pressure on the card it show me a menu, for that Menu I'm using ContextMenu, I'm using a navigationLink to show me a part that it let me Edit the card, but it doesn't show me the information that I want, for example I have a 4 card, and when y use contexMenu with card 1 it show me information of card 3. This is the code. VStack{     Grid{         LazyVGrid(columns: adaptiveColumns, spacing : 10){             ForEach($list) { $Category in                 NavigationLink(destination: CategoryList(list: $Category)){                     Card(list: Category).frame(height: 100)                         .contextMenu{                             Button { //                                                self.selectedCategory = $Category                                 editCategory = true                             } label: {                                 Text("Edit")                             }                         }                 }             }                          background{                 ForEach($list) { $list in                     NavigationLink("", destination: DetailCardView(list: $list), isActive : $editCategory)                 }             }         }     } } The background it's the code that I want that charge when I press the card using contexMenu
0
0
666
Feb ’23