I'm trying to allow the user to export a list of items to notes but for some reason, it's only exporting the first item and not the entire list like I would hope it was going to. This is my attempt at doing this...
guard let listId = list?.id else { return }
let ref = Database.database().reference().child("lists").child(listId).child("list-items")
ref.observe(.value) { (snapshot) in
guard let dict = snapshot.value as? [String: Any] else { return }
dict.forEach({ (key, value) in
let itemRef = Database.database().reference().child("items").child(key)
itemRef.observeSingleEvent(of: .value, with: { (snapshot) in
guard let dictionary = snapshot.value as? [String: Any] else { return }
guard let itemName = dictionary["item"] as? String else { return }
let activityController = UIActivityViewController(activityItems: [itemName], applicationActivities: nil)
self.present(activityController, animated: true, completion: nil)
})
})
}