2

Im trying to get data from a dictionary and appending it in a array (I followed this Tutorial).

This how the dictionary Looks like:

["Name": TEST, "ID": 51C3EE09-5718-4E07-9C88-FC2409BA6AC1, "Name_O": test, "Users": ]

but unfortunatly it fails to get the data

refHandle = ref.child("Pages").observe(.childAdded , with: { (snapshot) in
        if let dictionary = snapshot.value as? [String: AnyObject] {

            print(dictionary)

            let data = Data()

            data.setValuesForKeys(dictionary) //Error Happens Here "Thread Breakpoint"
            self.dataList.append(data)

            self.tableView.reloadData()

        }
    })

If I remove the line where the error was the array would look something like this:

[<app.Data: 0x786f4830>, <app.Data: 0x786f4ef0>]

Which confuses me...

instead of typing setValuesForKeys appenrently it supposed to be written setValuesForKeysWithDictionary (in Tutorial) but does not work anymore.

Thanks in advance for helping!

adjuremods
  • 2,938
  • 2
  • 12
  • 17
Adrien Zier
  • 687
  • 1
  • 7
  • 28

1 Answers1

2

As of Swift 3.0, it is now setValuesForKeys(_:) https://developer.apple.com/reference/objectivec/nsobject/1417515-setvaluesforkeyswithdictionary?language=objc

Swift is now open sourced and the community I suppose decided that instance method is unnecessarily long.

naomi
  • 58
  • 3