Display EDR content with Core Image, Metal, and SwiftUI

RSS for tag

Discuss the WWDC22 Session Display EDR content with Core Image, Metal, and SwiftUI

Posts under wwdc2022-10114 tag

2 Posts
Sort by:
Post not yet marked as solved
1 Replies
I use Core Data with two entities: Set and Link. Both entities contain a UUID id. Sets can contain 1 or more Links and this is represented in a 1-many relationship When the user wants to delete ALL links, this code is called for link in learningSet.webLinksArray.reversed(){       container.viewContext.delete(link) } do{ try container.viewContext.save() } catch let error { print("Failure deleting all links  } Here is the view code that renders link if !learningSet.webLinksArray.isEmpty{ LazyVGrid(columns: columns, alignment: .center, spacing: 16, pinnedViews: []) { ForEach(learningSet.webLinksArray, id: \.id) { link in  RichWebLinkView(webLink: link)      } } } It all works, but I get the following error/warning in the console ForEach<Array, Optional, ModifiedContent<ModifiedContent<DeckMiniView, _FrameLayout>, _FlexFrameLayout>>: the ID nil occurs multiple times within the collection, this will give undefined results! LazyVGridLayout: the ID nil is used by multiple child views, this will give undefined results! It's unclear why the LazyVGrid is even being re-rendered when the weblinksArray is empty. Im guessing this is happening while the delete for loop is running and the array isn't fully empty. Any suggestions on how to fix this would be appreciated.
Posted Last updated
Post marked as solved
1 Replies
I have a function like this @ViewBuilder   func addInfo(_ text: String, action: (() -> Void)?, addDivider: Bool = true, centerAlignment: Bool = false, isBold: Bool = false) -> some View {     VStack {       Text(text)         .fontWeight(isBold ? .bold : .regular)         .frame(maxWidth: .infinity, alignment: centerAlignment ? .center : .leading)         .padding([.leading, .trailing], 10)         .padding([.top, .bottom], 5)         .contentShape(Rectangle())         .onTapGesture {           if let action {             action()           }         }       if addDivider {         Divider()       }     }   } I do not understand why i get a compile error Expected type after '->' if i call the function like this addInfo("Sample", action: () -> Void {             }) The error points to Void. What is the correct way to do this? Please advise.
by chitgoks.
Last updated