I'm using the following :
(https://developer.apple.com/forums/thread/670303)
The little issue I'm facing now, is to display the dictionary. I'm using SwiftUI for my app UI.
Here is the code:
This is the error I'm having: Cannot convert value of type 'String?' to expected argument type 'Binding<String>'
If I unwrap this way :
I get this error: Cannot convert value of type 'String' to expected argumument type 'Binding<String>'
I'm getting the binding value data from what is on the NDEF tag
(https://developer.apple.com/forums/thread/670303)
Code Block Swift var data = "Key0:Value\nKey1:Value\nKey2:Value\nKey3:Value\n" var deciphered = data.split(separator: "\n").reduce(into: [String: String]()) { let str = $1.split(separator: ":") if let first = str.first, let value = str.last { $0[String(first)] = String(value) } }
The little issue I'm facing now, is to display the dictionary. I'm using SwiftUI for my app UI.
Here is the code:
Code Block Swift struct NFCMobileView: View { @Binding var data: String var body: some View { var deciphered = data.split(separator: "\n").reduce(into: [String: String]()) { let str = $1.split(separator: ":") if let first = str.first, let value = str.last { $0[String(first)] = String(value) } } HStack { Text("Last Name") TextField("", text: deciphered["lastName"]) /* error */ } } }
This is the error I'm having: Cannot convert value of type 'String?' to expected argument type 'Binding<String>'
If I unwrap this way :
Code Block Swift TextField("", text: deciphered["lastName"] ?? "")
I get this error: Cannot convert value of type 'String' to expected argumument type 'Binding<String>'
I'm getting the binding value data from what is on the NDEF tag