我想计算一个特定用户的登录次数,我知道这很容易就像问题一样但是,如果有人可以指导我一点,我在swift中很新:)
let nbConexion = PFUser.currentUser()!.objectForKey("nbconnexion") as? Int
if x = B{
(nbConexion)! + 1}

但似乎不起作用 谢谢
答案 0 :(得分:2)
Parse中有一个名为“Session”的类。它会自动记录应用程序上的每个登录信息,或者只是打开应用程序。
它有一个“用户”属性。所以你只是基本上查询用户当前用户的会话并打印数组计数:)
希望它有所帮助!
var query = PFQuery(className: "_Session")
query.whereKey("user", equalTo: PFUser.currentUser())
query.findObjectsInBackgroundWithBlock { (objects , error ) -> Void in
if error == nil{
print((objects as! [PFObject]).count)
}
}