Search code examples
swiftnsarraykeychain

Getting value of NSCoding into string - KeychainWrapper


I am using KeychainWrapper to store a dictionary value however retrieving the items in a string value has come at a problem.

I've tried the following:

KeychainWrapper.standard.object(forKey: "userOptions").unsafelyUnwrapped

Which prints,

(
  (
    value,
    value, 
    value
  )
)

And

KeychainWrapper.standard.object(forKey: "userOptions").unsafelyUnwrapped as! [Any]

which prints

(
   value,
   value, 
   value
)

These methods above still appear to be impossible for me to retrieve the string only value from the NSCoding array.


Solution

  • Try as,

    let userOptions = (KeychainWrapper.standard.object(forKey: "userOptions").unsafelyUnwrapped as! [[String]]).joined().joined(separator: " ") )