2016-09-25 37 views
0

我被困在試圖查詢類「帖子」中的所有行,首先屬於當前用戶,然後在同一列中輸入「魚」班級「職位」。解析服務器查詢以查找用戶名下的關鍵字

我能順利拿到屬於當前用戶的所有帖子:

let posts = PFQuery(className: "posts") 
    posts.whereKey("username", equalTo: PFUser.currentUser()!.username!) 
    posts.countObjectsInBackgroundWithBlock ({ (count:Int32, error:NSError?) in 
     if error == nil { 
      header.posts.text = "\(count)" 
     } 

我已經試過只需添加另一個whereKey第一下whereKey使用

posts.whereKey("fish", equalTo: "fish") 

但這並沒有工作。關於我需要做什麼來完成此任何想法?

回答

0

在解析中,您可以根據需要添加任意數量的條件。從你的代碼我認爲問題是你的第二個關鍵。在你的第二個,其中關鍵你正在努力尋找一切的魚下列,並在你的問題你寫,你要找到所有的類型列下的魚,所以請更改此

posts.whereKey("fish", equalTo: "fish") 

對此:

posts.whereKey("type", equalTo: "fish")