Любые идеи о том, что я могу сделать, чтобы исправить эту ошибку, я пытаюсь получить десять случайных чисел, поэтому я могу запросить firebase для набора вопросов, которые содержат случайные числа. Снимок экрана ниже. Я также добавил код ...Невозможно преобразовать значение типа 'Int' в ожидаемый тип аргумента 'UInt32'
import UIKit
import Firebase
class QuestionViewController: UIViewController {
var amountOfQuestions = 2
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
//Use a for loop to get 10 questions
for _ in 1...10{
//generate a random number between 1 and the amount of questions you have
var randomNumber = Int(arc4random_uniform(amountOfQuestions - 1)) + 1
//The reference to your questions in firebase (this is an example from firebase itself)
let ref = Firebase(url: "https://dinosaur-facts.firebaseio.com/dinosaurs")
//Order the questions on their value and get the one that has the random value
ref.queryOrderedByChild("value").queryEqualToValue(randomNumber)
.observeEventType(.ChildAdded, withBlock: {
snapshot in
//Do something with the question
println(snapshot.key)
})
} }
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func truepressed(sender: AnyObject) {
}
@IBAction func falsePressed(sender: AnyObject) {
}
Пробовали ли вы кастинг (amountOfQuestions - 1) к UInt32? – yesthisisjoe