Kann einen Wert vom Typ '[UInt32]' nicht tiefstellen

Ich habe ein Array von Zahlen, die zufällig generiert wurden, und ich versuche dann, Firebase nach einer Frage abzufragen, die dem Wert am Index [0] im Array der ausgewählten Zahlen entspricht. Das Problem im Moment ist, dass ich einen Fehler erhalteCannot subscript a value of type '[UInt32]'. P.S. Ich bin nicht sehr erfahren in Swift, so dass genaue Codelösungen sehr geschätzt werden würden! Ich habe auch meine Firebase-Struktur angehängt ...

import UIKit
import Firebase

class QuestionViewController: UIViewController {


let ref = Firebase(url: "https://123test123.firebaseio.com/questions")

override func viewDidLoad() {
    super.viewDidLoad()

    // An empty array to hold the selected numbers
    var selectedNumbers: [UInt32] = []

    // A range of acceptable numbers
    let randomNumberRange = 1...10

    // How many numbers are needed?
    let randomNumbersToChoose = 10

    // Crash if asking for more numbers than are available in the range
    assert(randomNumberRange.count >= randomNumbersToChoose, "Must have enough numbers to choose from!")

    // Repeat this loop until all enough numbers have been selected
    while selectedNumbers.count < randomNumbersToChoose {

        // Pick a random number within the allowed range
        let selectedNumber = arc4random_uniform(UInt32(randomNumberRange.endIndex - randomNumberRange.startIndex)) + UInt32(randomNumberRange.startIndex)

        // If it's not already in the selected array, add it
        if (selectedNumbers.indexOf(selectedNumber) == nil) {
            selectedNumbers.append(selectedNumber)
        }
    }

    // Print the result
    print(selectedNumbers)


        print(selectedNumbers)
        let selectedNumberIndex: UInt32 = 2
        ref.queryOrderedByChild("value").queryEqualToValue(selectedNumbers[0])
            .observeEventType(.ChildAdded, withBlock: {
                snapshot in
                //Do something with the question
                print(snapshot.key)
                print(snapshot.value.valueForKey("question"))
            })
    }

@IBAction func truepressed(sender: AnyObject) {
}

@IBAction func falsePressed(sender: AnyObject) {
}

}

JSON-Daten:

{
  "question1" : {
    "answer" : "Nohghpe",
    "question" : "Do you know swift",
    "value" : 1
  },
  "question10" : {
    "answer" : "A fdsbit",
    "question" : "Do you kndfggow firebase",
    "value" : 10
  },
  "question2" : {
    "answer" : "A bfhit",
    "question" : "Dodhfg you know firebase",
    "value" : 2
  },
  "question3" : {
    "answer" : "A bsdit",
    "question" : "Do you know firebsgdfase",
    "value" : 3
  },
  "question4" : {
    "answer" : "A vcxbit",
    "question" : "Do yosgfdu know firebase",
    "value" : 4
  },
  "question5" : {
    "answer" : "A bivcxt",
    "question" : "Do you kfghnow firebase",
    "value" : 5
  },
  "question6" : {
    "answer" : "A bxcvit",
    "question" : "Do you know fnhirebase",
    "value" : 6
  },
  "question7" : {
    "answer" : "A bivxct",
    "question" : "Do you sgdfknow firebase",
    "value" : 7
  },
  "question8" : {
    "answer" : "A bivcxt",
    "question" : "Do you knsfdow firebase",
    "value" : 8
  },
  "question9" : {
    "answer" : "A bdsfit",
    "question" : "Do you kdfgnow ffsdirebase",
    "value" : 9
  }
}

Antworten auf die Frage(2)

Ihre Antwort auf die Frage