2016-04-23 44 views
0

我检查了parse.com的quide文档,但我并不清楚。如何在Swift中使用Sql在Parse.com中“选择”

var query = PFQuery(className:"GameScore") 
query.whereKey("playerName", equalTo:"Sean Plott") 
query.findObjectsInBackgroundWithBlock { 
    (objects: [PFObject]?, error: NSError?) -> Void in 

    if error == nil { 
    // The find succeeded. 
    print("Successfully retrieved \(objects!.count) scores.") 
    // Do something with the found objects 
    if let objects = objects { 
     for object in objects { 
     print(object.objectId) 
     } 
    } 
    } else { 
    // Log details of the failure 
    print("Error: \(error!) \(error!.userInfo)") 
    } 
} 

我会试着告诉我想要用一个例子来做什么。我想 描述一个数组并将实体放入。

例如,如何将此查询的所有元素select followers from user where userid = 123放入数组中。

回答

0

好,我找到了办法

var query = PFQuery(className:"followers") 


    query.whereKey("follower", equalTo:"fmv0N91zAf") 
     query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in 

    if error == nil { 
    // The find succeeded. 
    print("Successfully retrieved \(objects!.count) scores.") 
    // Do something with the found objects 
    for object in objects! { 
     let following:String? = (object as! PFObject)["following"]as? String 
     if following != nil{ 
     self.deneme.append(following!) 
     } 
    }