Post

Replies

Boosts

Views

Activity

Reply to NSPersistentCloudKitContainer's canUpdateRecord always returns true.
FWIW It's a quite simple app slightly modified from the Xcode template for CoreData + CloudKit project. struct FeedbackContentView: View { @Environment(\.managedObjectContext) private var context @FetchRequest private var items: FetchedResults<Item> var body: some View { NavigationStack { List { ForEach(items) { item in let creator = CoreDataStack.shared.container.record(for: item.objectID)?.creatorUserRecordID?.recordName VStack(alignment: .leading) { Text(item.timestamp!.formatted()) Text("Mine") .foregroundStyle(.secondary) .opacity(creator == "__defaultOwner__" ? 1 : 0) Text("Can Edit? \(CoreDataStack.shared.container.canUpdateRecord(forManagedObjectWith: item.objectID))") // Always `true` } } } } } }
Oct ’24
Reply to ScrollPosition.scrollTo(id:, anchor:) not behaving as expected
I was able to achieve the same behavior by changing the anchor of scrollPosition(_:anchor:) to match scrollTo(id:anchor:) before calling: struct ContentView: View { @State private var position = ScrollPosition(edge: .top) @State private var anchor: UnitPoint? var body: some View { NavigationStack { ScrollView { VStack(spacing: 8) { ForEach(1..<100) { index in Text(verbatim: index.formatted()) .frame(maxWidth: .infinity) .background(.gray) .id(index) } } } .scrollPosition($position, anchor: anchor) .toolbar { ToolbarItemGroup(placement: .bottomBar) { Spacer() Button("50 (T)") { anchor = .top withAnimation { position.scrollTo(id: 50, anchor: .top) } } Button("50 (B)") { anchor = .bottom withAnimation { position.scrollTo(id: 50, anchor: .bottom) } } Spacer() } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’25
Reply to Behavior of Image and ignoresSafeArea
I think my solid color image was a bad example because it works fine with just resizable() 😅 But a picture would be distorted without scaledToFill(). I've found another solution using an alignment value of background that is opposed to the ignored edges: .background(alignment: .bottom) { Image(.background) .resizable() .ignoresSafeArea(edges: .top) .scaledToFill() }
Topic: UI Frameworks SubTopic: SwiftUI
Jul ’25