如何使用Relationship来使用swift在Parse Server上检索图像

时间:2016-09-29 00:00:32

标签: swift parse-platform parse-server pfquery

新解析,我通过文档但我没有理解关系的概念......

我有一对多的关系(产品 - >多种颜色变化)。

解析时,在我的班级"产品"我有以下专栏: 品牌,尺寸,价格,颜色。

颜色单元是一种挂钩"颜色" class,包含: Color_Name,Color_Image(作为文件)。

如何访问color_name& color_image?我正在使用下面的代码,但是我将返回nil。

func searchCategoryItems(){

categoryType = "basketball"

let query:PFQuery = PFQuery(className: "products")
                query.includeKey("color")
                let productQuery = query.whereKey("type", equalTo:self.categoryType)

                productQuery.findObjectsInBackgroundWithBlock {
                    (objects, error) -> Void in

                    for object in objects! {
                        let brandName:String? = (object as PFObject)["brand"] as? String
                        let itemName:String? = (object as PFObject)["item_name"] as? String
                        let sku:String? = (object.objectId! as String)
                        let colors:String? = (object as PFObject)["color_name"] as? String
                        if colors != nil{
                        self.productColorArray.append(colors!)
                        print("colors work?", colors)
                        }

                        if brandName != nil {
                            self.productBrandArray.append(brandName!)
                        }
                        if itemName != nil{
                            self.productItemNameArray.append(itemName!)
                        }
                        if sku != nil{
                            self.productSkuArray.append(sku!)
                        }


                    }

                    self.searchTableView.reloadData()
                }
                self.searchTableView.insertRowsAtIndexPaths([NSIndexPath(forRow:0,inSection:0)], withRowAnimation: UITableViewRowAnimation.Automatic)
            }
    }

这就是我的解析仪表板:

products class

color class

1 个答案:

答案 0 :(得分:0)

您需要执行其他关系查询。

spring security