如果条件满足,有没有办法从PFQuery中删除行?

时间:2015-06-08 20:44:31

标签: ios uitableview swift parse-platform pfquerytableviewcontrolle

如果从var cellStatus = object["active"] as! Bool检索到的条件为false,我尝试删除一行。我尝试过几种不同的东西,似乎无法开展任何工作。隐藏单元格只会在tableView中留下很大的空白。

class TableViewController: PFQueryTableViewController {

    override init(style: UITableViewStyle, className: String!) {
        super.init(style: style, className: className)
    }

    required init(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)

        self.parseClassName = "specials"
        self.pullToRefreshEnabled = true
    }

    // Define the query that will provide the data for the table view
    override func queryForTable() -> PFQuery {
        var query = PFQuery(className: parseClassName!)
        query.limit = 6
        query.orderByAscending("specialRank")
        return query
    }

    //override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject!) -> PFTableViewCell {

        var cellStatus = object["active"] as! Bool

        var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! PFTableViewCell!

        if cell == nil {
            cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")
        }

        if let locationName = object["locName"] as? String {
            cell?.textLabel?.text = locationName
        }
        if let spec = object["special"] as? String {
            cell?.detailTextLabel?.text = spec
        }

        return cell
    }

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        // Get the new view controller using [segue destinationViewController].
        var detailScene = segue.destinationViewController as! DrinkInfoViewController

        // Pass the selected object to the destination view controller.
        if let indexPath = self.tableView.indexPathForSelectedRow() {
            let row = Int(indexPath.row)
            detailScene.currentObject = objects?[row] as? PFObject!
        }
    }

    override func viewWillAppear(animated: Bool)    
    {
        self.navigationController?.navigationBarHidden = false
    }
}

0 个答案:

没有答案
相关问题