Post

Replies

Boosts

Views

Activity

Reply to Strange SwiftUI bug (just making sure if it's a bug or not)
OK I found out why Compiler found a bug in our code of the body of the Stack Instead of telling SwiftUI checking the body of the VStack it thinks it's a faulty initialization So when we use @absar's method it forced SwiftUI into initalizing as it should and therefore, find out the bug in our code in body. or rather: VStack(body: { .... }) but after you fix your bug it should be back to normal. Please continue to post if you have any other infos. Thanks!
Jul ’22
Reply to @AppStorage
OK found it out myself: https://www.jianshu.com/p/7591a7cd5eb1 I can do extension Array: RawRepresentable where Element: Codable { public init?(rawValue: String) { guard let data = rawValue.data(using: .utf8), let result = try? JSONDecoder().decode([Element].self, from: data) else { return nil } self = result } public var rawValue: String { guard let data = try? JSONEncoder().encode(self), let result = String(data: data, encoding: .utf8) else { return "[]" } return result } } Also Date: extension Date: RawRepresentable{ public typealias RawValue = String public init?(rawValue: RawValue) { guard let data = rawValue.data(using: .utf8), let date = try? JSONDecoder().decode(Date.self, from: data) else { return nil } self = date } public var rawValue: RawValue{ guard let data = try? JSONEncoder().encode(self), let result = String(data:data,encoding: .utf8) else { return "" } return result } }
Jul ’22