保存数组以进行解析

时间:2017-06-10 23:35:32

标签: ios objective-c swift parse-platform swift3

我有一堆数据我正在保存为一个pfobject进行解析,我将它们保存在单独的字段中。我的问题是,最后我希望能够搜索这些数据,访问所有字段,但这是非常低效的。有人建议我把字段保存在一个数组中。但我不知道该怎么做,我到处寻找。如何在一个数组中保存PriceText和ViewsText的底部两个字段并保存该字符串数组。下面是代码。

let table = PFObject(className: "Example")
        table["Price"] = PriceText
        table["Views"] = ViewsText
        table.saveInBackground { (success:Bool, error:Error?) -> Void in
            if success {

            }else{

            }
        }
         var query : PFQuery<PFObject>!
         query.order(byDescending: "createdAt")
        let fiel1 = PFQuery(className: "Real Estate")
        field1.whereKey("field one", contains: search)
        let field2 = PFQuery(className: "Real Estate")
        field2.whereKey("field two", contains: search)
        let field3 = PFQuery(className: "Real Estate")
        field3.whereKey("field three", contains: search)
        let field4 = PFQuery(className: "Real Estate")
        field3.whereKey("field four", contains: search)
        let field5 = PFQuery(className: "Real Estate")
        field5.whereKey("field 5", contains: search)
        let field6 = PFQuery(className: "Real Estate")
        field6.whereKey("field 6", contains: search)
        let field7 = PFQuery(className: "Real Estate")
        field7.whereKey("field 7", contains: search)
        let field8 = PFQuery(className: "Real Estate")
        field8.whereKey("field 8", contains: search)
        let field9 = PFQuery(className: "Real Estate")
        field9.whereKey("field 9", contains: search)
        let field10 = PFQuery(className: "Real Estate")
        field10.whereKey("field 10", contains: search)
        let field11 = PFQuery(className: "Real Estate")
        field11.whereKey("field 11", contains: search)
        let field12 = PFQuery(className: "Real Estate")
        field12.whereKey("field 12", contains: search)
        let field13 = PFQuery(className: "Real Estate")
        field13.whereKey("field 13", contains: search)
        let field14 = PFQuery(className: "Real Estate")
        field14.whereKey("field 14", contains: search)
        let field15 = PFQuery(className: "Real Estate")
        field15.whereKey("field 15", contains: search)
        let field16 = PFQuery(className: "Real Estate")
        field16.whereKey("field 16", contains: search)
        let field17 = PFQuery(className: "Real Estate")
        field17.whereKey("field 17", contains: search)
        let field18 = PFQuery(className: "Real Estate")
        field18.whereKey("field 18", contains: search)
        let field19 = PFQuery(className: "Real Estate")
        field19.whereKey("field 19", contains: search)
        let field20 = PFQuery(className: "Real Estate")
        field20.whereKey("field 20", contains: search)
        let field21 = PFQuery(className: "Real Estate")
        field21.whereKey("field 21", contains: search)
        let field22 = PFQuery(className: "Real Estate")
        field22.whereKey("field 22", contains: search)
        let field23 = PFQuery(className: "Real Estate")
        field23.whereKey("field 23", contains: search)
        let field24 = PFQuery(className: "Real Estate")
        field24.whereKey("field 24", contains: search)
        let field25 = PFQuery(className: "Real Estate")
        field25.whereKey("field 25", contains: search)
        let field26 = PFQuery(className: "Real Estate")
        field26.whereKey("field 26", contains: search)
        let field27 = PFQuery(className: "Real Estate")
        field27.whereKey("field 27", contains: search)
        let field28 = PFQuery(className: "Real Estate")
        field28.whereKey("field 28", contains: search)
        let field29 = PFQuery(className: "Real Estate")
        field29.whereKey("field 29", contains: search)
        let field30 = PFQuery(className: "Real Estate")
        field30.whereKey("field 30", contains: search)
        let objectId = PFQuery(className: "Real Estate")
        objectId.whereKey("objectId", contains: search)
        query = PFQuery.orQuery(withSubqueries: [field1, field2, field3, field4, field5, field6, field7, field8, field9, field10, field11, field12, field13, field14, field15, field16, field17, field18, field19, field20, field21, field22, field23, field24, field25, field26, field27, field28, field29, field30, objectId])

0 个答案:

没有答案