输入'任何'没有Firebase的下标成员

时间:2017-02-20 03:14:47

标签: ios swift firebase firebase-realtime-database

我知道之前已经讨论过这个主题,但是我还没有在我的代码中找到StackOverflow的解决方案。我该怎么做才能更新我的代码,以便在Swift 3上运行?我在Swift 2.2中没有这些错误

这就是我格式化代码的方式:

import Foundation
import Firebase
import FirebaseDatabase
import FirebaseStorage


struct Comment {
    var image: String!
    var postID: String!
    var description: String!
    var username: String!
    var price: String!
    var rating: String!
    var title: String!
    var ref: FIRDatabaseReference?
    var key: String!


    init(postID: String, image: String, description: String, username: String, title: String, rating: String, price: String, key: String = ""){

        self.description = description
        self.postID = postID
        self.username = username
        self.title = title
        self.rating = rating
        self.price = price
        self.image = image
        self.ref = FIRDatabase.database().reference()


    }

    init(snapshot: FIRDataSnapshot){

        self.description = snapshot.value!["description"] as! String // error here
        self.postID = snapshot.value!["postID"] as! String // error here
        self.title = snapshot.value!["title"] as! String // error here
        self.rating = snapshot.value!["rating"] as! String // error here
        self.price = snapshot.value!["price"] as! String // error here
        self.image = snapshot.value!["image"] as! String // error here
        self.key = snapshot.key
        self.ref = snapshot.ref




    }

    func toAnyObject() -> [String: AnyObject] {

        return ["image": image, "description": description , "username": username, "postId": postID, "title": title, "rating": rating, "price": price]
    }


}

2 个答案:

答案 0 :(得分:0)

试试这个 - :

ListView.ItemTemplate

答案 1 :(得分:0)

以下代码适用于您的情况:

new SoqlQueryBuilder()
            .addSelectPhrase(field1)
            .addGroupByPhrase(field1)
            .build();

让我们知道你有什么。