Post

Replies

Boosts

Views

Activity

Reply to multiple background requests
Use one session, according to Use Background Sessions Efficiently I noticed if you init a session with a config with the same identifier you will actually get the previous instance. I assume you have to set a taskDescription on the task to be able to identify it in .backgroundTask() on the Scene, where presumably you have to retrieve all the completed tasks from the session and deal with the results.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to SwiftUI EditButton problem in Xcode 12 beta
The problem is ForEach with id: \.self for a dynamic array of value types is a major mistake unfortunately made by many developers, anyone know why? The documentation states that id needs to be "The key path to the provided data’s identifier." E.g. id: \.uniqueIdentifier, or preferably conform your model struct to Identifiable and implement either let id = UUID() or var id: String { return a calculated id from other vars }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’22
Reply to ForEach Breaks Data Binding
The ForEach View cannot not work with indicies for dynamic data, it requires identifiers which is why we supply it with an array of Identifiable data. This is so that it can calculate inserts, moves and deletions which obviously is impossible with an array of indicies which will in the case of moving 5 items around the indices will still be 0-4.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Feb ’22
Reply to SwiftUI: @StateObject never deinitialized
In SwiftUI we don't use view model objects. The View structs (or custom @State structs) hold the data that SwiftUI uses to diff and update the screen. View models are a UIKit pattern don't use it in SwiftUI, if you do then you'll add an unnecessary level of indirection and slow SwiftUI down and lose a lot of the magic behaviour.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Dec ’21
Reply to modifyRecordsCompletionBlock deprecated on iOS 15
I think we have to keep using modifyRecordsCompletionBlock because modifyRecordsResultBlock doesn't error on server record changed, it erroneously reports success. As of Xcode 14b1 iOS 16b1. See this post for more info.
Topic: App & System Services SubTopic: iCloud Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to multiple background requests
Use one session, according to Use Background Sessions Efficiently I noticed if you init a session with a config with the same identifier you will actually get the previous instance. I assume you have to set a taskDescription on the task to be able to identify it in .backgroundTask() on the Scene, where presumably you have to retrieve all the completed tasks from the session and deal with the results.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jun ’22
Reply to SwiftUI EditButton problem in Xcode 12 beta
The problem is ForEach with id: \.self for a dynamic array of value types is a major mistake unfortunately made by many developers, anyone know why? The documentation states that id needs to be "The key path to the provided data’s identifier." E.g. id: \.uniqueIdentifier, or preferably conform your model struct to Identifiable and implement either let id = UUID() or var id: String { return a calculated id from other vars }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’22
Reply to ForEach Breaks Data Binding
The ForEach View cannot not work with indicies for dynamic data, it requires identifiers which is why we supply it with an array of Identifiable data. This is so that it can calculate inserts, moves and deletions which obviously is impossible with an array of indicies which will in the case of moving 5 items around the indices will still be 0-4.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Feb ’22
Reply to I'm unable to use the withTaskCancellaionHandler without a static analysis error
You could try this workaround: var cancelable: AGSCancelable? let onCancel = { cancelable?.cancel() } return try await withTaskCancellationHandler { onCancel() } operation: {
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to SwiftUI: @StateObject never deinitialized
In SwiftUI we don't use view model objects. The View structs (or custom @State structs) hold the data that SwiftUI uses to diff and update the screen. View models are a UIKit pattern don't use it in SwiftUI, if you do then you'll add an unnecessary level of indirection and slow SwiftUI down and lose a lot of the magic behaviour.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to SwiftUI Navigation Stack pops back on ObservableObject update
isDetailLink(false) on the NavigationLink will fix this problem
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to View body is called although its @Binding has not changed
To avoid this do: struct InsideView: View { let value: Int // … } @Binding is for when we want write access to the state.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21
Reply to Showing sheet dismiss navigation view child
There is a mistake. You need to move your NavigationView into Tab1. Also remove the ZStack. struct Tab1: View { @State var shownextPage = false var body: some View { NavigationView{ NavigationLink( destination: SecondView(), isActive: $shownextPage) { Text("Next Page") } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Dec ’21