This is my code. I asked for help previously but got no response but I think I have fixed it. Essentially, want to disable a button if the count is higher than a specific number. I am printing out the count and it is correct however when I implement it in a if else statement, it is not working.
What am i doing wrong? Any help would be greatly appreciated! Thanks.
func checkPurchase() {
guard let uid = Auth.auth().currentUser?.uid else { return }
Database.database().reference().child("users").child(uid).child("Posts").observe(DataEventType.value, with: { (snapshot) in
print(snapshot.childrenCount)
let imagesPurchase = snapshot.childrenCount
print(imagesPurchase)
Purchases.shared.purchaserInfo { [weak self] info, error in
guard let info = info, error == nil else { return }
if info.entitlements.all["Premium"]?.isActive == false && snapshot.childrenCount < 0 {
DispatchQueue.main.async {
self?.AddPicture.isEnabled = false
}
} else {
print("Hi")
}
}
}
)
}
Aucun commentaire:
Enregistrer un commentaire