Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用Swift停用/激活Firebase上的用户帖子_Ios_Swift_Firebase_Firebase Realtime Database_Swift4 - Fatal编程技术网

Ios 使用Swift停用/激活Firebase上的用户帖子

Ios 使用Swift停用/激活Firebase上的用户帖子,ios,swift,firebase,firebase-realtime-database,swift4,Ios,Swift,Firebase,Firebase Realtime Database,Swift4,我在Firebase中有两个帖子节点,public\u posts和user\u posts。我希望用户停用他们的帖子,而不是永久删除帖子。因此,在将来,如果用户想要激活回发帖,他们可以 user\u posts节点将包含由经过身份验证的用户创建的帖子。因此,显示经过身份验证的用户帖子的视图控制器可以在一个简单的标签中显示帖子是否被激活或停用 public\u posts包含对公众可见的帖子。但是,我不希望公共视图控制器显示停用的用户帖子 "public_posts" : { "Home"

我在Firebase中有两个帖子节点,public\u postsuser\u posts。我希望用户停用他们的帖子,而不是永久删除帖子。因此,在将来,如果用户想要激活回发帖,他们可以

user\u posts节点将包含由经过身份验证的用户创建的帖子。因此,显示经过身份验证的用户帖子的视图控制器可以在一个简单的标签中显示帖子是否被激活或停用

public\u posts包含对公众可见的帖子。但是,我不希望公共视图控制器显示停用的用户帖子

"public_posts" : {
  "Home" : {
    "Single Room" : {
      "-Kx-oQs5MEmnC5wTdXBr" : {
        "description" : "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum",
        "location" : "United States",
        "title" : "Room for rent"
      }
    }
  }
},
"user_posts" : {
  <$uid> : {
    "-Kx-oQs5MEmnC5wTdXBr" : {
      "category" : "Home",
      "description" : "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum",
      "location" : "United States",
      "subCategory" : "Single Room",
      "title" : "Room for rent"
    }
  }
}
guard let userId = Auth.auth().currentUser?.uid else {
            return
        }
let ref = Database.database().reference()        
ref.child("user_posts").child(userId).observe(.childAdded, with: { (snapshot) in

          if let value = snapshot.value as? [String:AnyObject]{
                  value["title"] as? String
                  //etc...
                }

        }, withCancel: nil )