Is there a good way to rename an array's title in Swift? For example, I'd like to be able to change the array title "Cats" to "Dogs" (without it losing its values). I was updating the entire "Animals" dictionary, but surely there's a more efficient way to do this (update just the single sub-dictionary title).
Dictionary setup:
" Animals " (main dictionary)
-> Cats (sub-dictionary)
-> -> "Jimmy", "Lola", "Timmy" (cat names)
let db = Firestore.firestore()
guard let userID = Auth.auth().currentUser?.uid else {
print("The user is not signed into an account.")
return
}
if userID.isEmpty != true {
// Inside the "Animals" array, change the "Cats" dictionary title to "Dogs"
}
There is no specific operation to rename a field, so you'll have to perform the operation by:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.