1

I have a very simple dictionary:

let dict = ["name": "John", "surname": "Doe"]

But when I try to access to the keys of the dictionary I get this error:

Keys(_variantBuffer: Swift._VariantDictionaryBuffer<Swift.String, Swift.String>.native(Swift._NativeDictionaryBuffer<Swift.String, Swift.String>(_storage:

Here is the complete implementation:

override func viewDidLoad() {
        super.viewDidLoad()
        let array = [1,2,3,4,6,5]
         let dict = ["name": "John", "surname": "Doe"]
        print(array)
        print(dict.keys)
    }

Any of you knows why I'm getting this error? or how can fix this?

I'll really appreciate your help

enter image description here

Community
  • 1
  • 1
user2924482
  • 8,380
  • 23
  • 89
  • 173
  • https://stackoverflow.com/questions/26386093/array-from-dictionary-keys-in-swift ? Use `Array(dict.keys)`? – Larme Mar 29 '18 at 19:53
  • Literally just added those exact same lines on my iOS App and it worked: `override func viewDidLoad() { let array = [1,2,3,4,6,5] let dict = ["name": "John", "surname": "Doe"] print(array) print(dict.keys)` Possibly a build setting? – kailoon Mar 29 '18 at 19:58
  • @kailoon this is very weird – user2924482 Mar 29 '18 at 19:59
  • @Larme this worked `print(Array(dict.keys))` – user2924482 Mar 29 '18 at 19:59
  • now I would really like to know WHY this happens.. I would expect that a public member would not crash on printing.. – Milan Nosáľ Mar 29 '18 at 21:34
  • I'd consider it a bug. I'd suggest filing a [bug report](http://bugreport.apple.com). – Rob Mar 29 '18 at 21:55

0 Answers0