【问题标题】:How to block users in my app (swift + parse)如何在我的应用程序中阻止用户(swift + parse)
【发布时间】:2017-10-17 04:06:53
【问题描述】:

我正在使用 parse 构建一个应用程序,用户可以在其中单击地图中的注释并查看该地点的图片。 我的问题是阻止按钮......它不起作用,当用户点击阻止按钮时,他不应该看到他阻止的用户的任何注释,但不幸的是不起作用。

这是我的阻止按钮:

@IBAction func blocking(_ sender: Any) {
    let block = PFObject(className: "blocking")

    block["me"] = PFUser.current()?.username
    block["poster"] = post?.name
    block["posterID"] = post?.id

    block.saveInBackground { (succ, error) in
        if error != nil {

            print("rttot")
        } else {

            self.performSegue(withIdentifier: "mo", sender: nil)
        }
    }
}

(注意poster ID是图片发帖人的ID,poster是发帖人的名字)

此操作将启动用户与阻止用户之间的关系。现在我不会显示任何持有我要屏蔽的人 ID 的帖子。

    let queryy = PFQuery(className: "blocking")
    queryy.whereKey("me", equalTo: PFUser.current()?.username)
    queryy.findObjectsInBackground { (objects, error) in
        if error != nil {

            print("error")

        } else {



            for object in objects! {
                if let neww = object.object(forKey: "posterID") {


     var query = PFQuery(className: "posts")
     query.whereKey("id", notEqualTo: neww)
      query.findObjectsInBackground { (objects, error) in
         if error != nil {

            print("error")

           } else {



              for object in objects! {   

                   let post = Posts()

                   post.chosen = object.object(forKey: "chosen") as! String

                  post.lati = object.object(forKey: "lati") as! Double
                   post.longi = object.object(forKey: "longi") as! Double
                post.image = object.object(forKey: "image") as? PFFile
                    post.text = object.object(forKey: "text") as! String
                post.name = object.object(forKey: "name") as! String
                   post.uid = object.object(forKey: "uid") as! String
                 post.id = object.object(forKey: "id") as! String



                print("999")

                var cord = CLLocationCoordinate2D(latitude: post.lati, longitude: post.longi)


                let anno = annoClass(cord: cord, post: post, text: "Destination", subText: "ClickMe")

                self.myMap.addAnnotation(anno)


            }



           }

     }
    }

                    }

                }

            }

如您所见,它将获取我正在阻止的人的 ID,并且不会在地图中显示他们的帖子,但这不起作用。顺便说一句,该应用程序没有显示任何错误或错误。

【问题讨论】:

    标签: ios swift parse-platform


    【解决方案1】:

    试试这个

        queryy.whereKey("User_has_Blooked", equalTo: false) // if its equal to true, it should not show the users. make this object in the same class when you fetch users in the map! 
    

    【讨论】:

      猜你喜欢
      • 2015-03-01
      • 2019-05-18
      • 2012-07-12
      • 1970-01-01
      • 1970-01-01
      • 2018-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多