swift - How can I fix this Result values in '? :' expression have mismatching types 'String' and '[Any]?' -


i have following lines of code:

let string:string = "" let extracted_data:string! = (response?.extracted_data == nil) ? "" : response?.extracted_data string.append("\(extracted_data)") 

extracted_data [any]. can't figure out why getting error:

result values in '? :' expression have mismatching types 'string' , '[any]?'

you should parsing variable [any] type of array , later on if know array contains string type should doing this. take first element out of array , set value

response?.extracted_data?.first as? string ?? "default value if string not present" 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -