Questions tagged [identifiable]

Swift protocol used to uniquely identify instances.

Identifiable is a Swift protocol used to uniquely identify instances. You must implement the id computed-property to satisfy the protocol requirements.

Apple's description:

A class of types whose instances hold the value of an entity with stable identity.

Commonly used in conjunction with SwiftUI's ForEach.

37 questions
0
votes
0 answers

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: Identifiable { var i1: UInt var i2: UInt var i3: UInt var…
0
votes
1 answer

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 protocol, I am unable to use CustomModel as an…
Nizami
  • 728
  • 1
  • 6
  • 24
0
votes
0 answers

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 PERFECTLY ScrollView { …
LukeSideWalker
  • 7,399
  • 2
  • 37
  • 45
0
votes
0 answers

Structural identifiability of a model

Is there some python library that would do the stuctural identifiability of a model? My model is analitically solvable linear differential equation that involves 3 parameters. I would like to know if after fitting this equation to the data, obtained…
Alicja
  • 1
  • 1
0
votes
2 answers

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. My achievement view is being called to run in a…
0
votes
0 answers

Correlation of parameters in a model

I would like to know if the parameters of my model are identifiable. Does a high correlation between parameters, which are shown as a result of fit, a sign of parameters unidentifiability? [[Variables]] alpha: 3.63101902 +/- 0.42188236…
Alicja
  • 1
  • 1
0
votes
1 answer

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 (second level). Important is that each of the…
Christina
  • 3
  • 2
0
votes
1 answer

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 update when the button is clicked, because the…
esilver
  • 27,713
  • 23
  • 122
  • 168
0
votes
1 answer

Identifiable as generic and func parameter

Hello I want to build something like below: protocol BaseEntity: Identifiable { var id: UUID { get set } } protocol DataStore { associatedtype T: BaseEntity typealias CompleteHandler = ((Result) -> Void) func…
piotr_ch
  • 508
  • 3
  • 7
  • 17
0
votes
1 answer

issues with conformance to Identifiable with id: Optional

I want to make my custom list in SwiftUI. I tried to mimic this List’s initializer: public init( _ data: Data, selection: Binding?, @ViewBuilder rowContent: @escaping (Data.Element) -> RowContent )…
alageev
  • 3
  • 1
0
votes
1 answer

Make ScrollViewReader scroll to item using a list and identifiable protocol in SwiftUI

I can't make ScrollViewReader to scroll on my List(). I have read many discussions such this or this I use a model with Identifiable protocol and id as Int: struct Country: Identifiable, Codable, Hashable { // database fields var…
alex.bour
  • 2,842
  • 9
  • 40
  • 66
0
votes
3 answers

Can a Swiftui Identifiable Foreach loop select only the first 5 items

Howdy I have a project that only needs to display the first 5 items in the loop of over 30 items, below is my code struct Introductions: Codable, Identifiable { let id: String let topIntros: String? let image: String let date:…
EMPIRE
  • 57
  • 7
0
votes
1 answer

SwiftUI - using ForEach with a Binding array that does not conform to identifiable / hashable

I have the a codable object as follows: struct IncidentResponse: Codable { let incident: IncidentDetails? } struct IncidentDetails: Codable, Identifiable { let id: String? let reason: IncidentReasonResponse? let message: String? …
DevB1
  • 1,235
  • 3
  • 17
  • 43
0
votes
2 answers

SwiftUI: How to manage dynamic rows/columns of Views?

I am finding my first SwiftUI challenge to be a tricky one. Given a set of playing cards, display them in a way that allows the user to see the full deck while using space efficiently. Here's a simplified example: In this case 52 cards (Views) are…
pauln
  • 598
  • 6
  • 19
0
votes
2 answers

Make Core Data entity (with existing `id` attribute) conform to Identifiable?

I have a Core Data entity that has an attribute named id: @NSManaged public var id: Int As I work with SwiftUI, I am adding support for Identifiable, so then the Core Data entity now conforms to it: extension Car : Identifiable { } When I try to…
zumzum
  • 17,984
  • 26
  • 111
  • 172