43 questions
0
votes
2
answers
46
views
SwiftUI List support selection with different model types
I am trying to implement a SwiftUI list for a sidebar view which has at least 3 different types of data points: a) a fixed list of enums, b) a list of 'tags' coming from a @FetchRequest using Core ...
0
votes
1
answer
38
views
SwiftUI - Comparison of a Binding variable in onTapGesture (to toggle selection of a row in a Grid)
I'm able to get a row item selected using onTapGesture, and deselected if it is tapped again.
The question is why does the following code work, but the code shown at the end did not?
@Binding var ...
-2
votes
1
answer
366
views
Protocol 'Identifiable' requires 'id' to be available in iOS 16.0 and newer
Creating Tipkit but this error is appearing, complete beginner any help would be much appreciated Xcode Image Please Give Code solution
import Foundation
import TipKit
struct Example: Tip { // ...
0
votes
1
answer
75
views
Filter elements of a String variable contained in an Identifiable
I'm coding a Swift application for macOS.
I'm a beginner in Swift so my problem might seem stupid to you, I apologize for that...
I have a type containing the following two String variables:
struct ...
1
vote
1
answer
66
views
How do you make data in an array nested within JSON data identifiable so you can list the data?
My goal is to display some data from a JSON file in a List in SwiftUI. This is for iOS 17. I have tried a lot of different things and have done some research, but cannot find the solution.
Here's an ...
-2
votes
1
answer
83
views
Why does computed "id" create this alleged ambiguity?
I have a pet peeve against the misuse of "id" to mean "ID." Unfortunately, the Identifiable protocol requires a hard-coded member called id for conformance; fortunately you can use ...
0
votes
0
answers
241
views
Error in my List' Initializer 'init(_:id:rowContent:)' requires that 'ShopsModel' conform to 'RandomAccessCollection'"
I have a struct for ShopsModel that complies to Identifiable.
struct ShopsModel: Identifiable {
var id: Int
var shopName: String
var postcode: String
var type: String
}
I have two ...
0
votes
0
answers
54
views
Identifiable class's id generation by multiple properties but too complex, How can I solve the problem?
I have to compare a lot of objects.
In order to improve speed, I want to make 'id' like the below code.
Unfortunately, Swift compiler can't process this code.
How can I fix it?
struct OBJ: ...
1
vote
1
answer
705
views
Custom protocol does't support Identifiable in SwiftUI
I have defined a CustomProtocol, which requires a unique identifier. I have also created a CustomModel that implements this protocol. Despite having an id property as required by the Identifiable ...
0
votes
1
answer
208
views
Why Picker requires 'Hashable', when the model is already 'Identifiable' ? Why this requirement comes not up on ScrollView?
When moving the following 'ForEach' code into a Picker, the compiler complaints with: "Generic struct 'Picker' requires that 'Currency' conform to 'Hashable'":
// THIS WORKS ...
-1
votes
1
answer
397
views
How to conform an Array to 'Identifiable'
I'm confused about how Identifiable arrays work. For instance, I have the following array returned as a response to a function:
Optional (["Jane", "John", "Eric", "...
0
votes
2
answers
269
views
How to change value from an identifiable object in one view from another view swiftui
I am making an achievement system in my app, i want people to be awarded for using my app. Im trying to change the isComplete value from content view, for the identifiable object in achievement view. ...
0
votes
1
answer
1k
views
SwiftUI - Iterate through a @State or @Published dictionary with ForEach
I have an array of Strings, "categories", and associated to each category I have an "Item" struct in another array. With these I have formed a dictionary of type [String: [Item]].
...
0
votes
1
answer
1k
views
Create list with NavigationLink items in SwiftUI where each NavigationLink again contains a list of items which is individual
[Pic 1 AS IS]
[Pic 2 TO BE]
Hi there,
I am just starting to learn Swift an I would like my app users to build their own list of items (first level) where each item again contains a list of items (...
0
votes
1
answer
709
views
How does LazyVStack choose to re-render if Identifiable is constant?
How does a LazyVStack in SwiftUI decide if it needs to re-render a View, assuming the Identifiable property of an item it is rendering does not change?
This trivial demo code below, I feel, should not ...