Before anyone marks this question as duplicate or so of Exact Same Question here, I would like to add that i’ve tried the mentioned methods and still cannot resolve.
I’m working on a new project and to take the advantage of the new features and resources available in Swift/SwiftUI for faster build and to minimize the app size, I’m only using the official libraries. The project is almost completed and I’ve tried my best to resolve any warnings (deprecation and others) in my codebase. But there is only this one warning i cannot get around.
Here is my struct and i’m using this in a list.
struct RewardObj: Codable, Identifiable{
let id = UUID() // WARNING HERE
var redeemAble: Bool? = false
let RewardID: String?
...
}
I’ve tried to make the UUID() as var id = UUID()
but then the data is not decoded and exception is thrown.
I’ve tried to make it optional and then assign the value as var id: UUID? = UUID()
and now only one item is loaded.
Have tried to use computed property as var id = UUID {return UUID()}
and using getter as var id = UUID {get{return UUID()}}
and in both cases 1/10 times loads the list but makes the app lag and will crash the app within seconds and the memory graph just shoots.
I’ve this same warning in 4 other places and cannot get around.
Any suggestion is appreciated.