Earlier than anybody marks this query as duplicate or so of Actual Identical Query right here, I wish to add that i’ve tried the talked about strategies and nonetheless can not resolve.
I am engaged on a brand new venture and to take the benefit of the brand new options and assets out there in Swift/SwiftUI for quicker construct and to reduce the app measurement, I am solely utilizing the official libraries. The venture is sort of accomplished and I’ve tried my finest to resolve any warnings (deprecation and others) in my codebase. However there’s solely this one warning i can not get round.
Right here is my struct and i am utilizing this in an inventory.
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()
however then the information is just not decoded and exception is thrown.
I’ve tried to make it optionally available after which assign the worth as var id: UUID? = UUID()
and now just one merchandise is loaded.
Have tried to make use of computed property as var id = UUID {return UUID()}
and utilizing getter as var id = UUID {get{return UUID()}}
and in each instances 1/10 instances masses the record however makes the app lag and can crash the app inside seconds and the reminiscence graph simply shoots.
I’ve this identical warning in 4 different locations and can’t get round.
Any suggestion is appreciated.