Reputation: 611
I'm getting the error with the following code in my cellForRowAt
method:
self.db.collection("myCollection").document(self.currentUser!).updateData(["myArray":FieldValue.arrayRemove(myArray![indexPath.row])]).
The Cannot convert value of type 'String' to expected argument type '[Any]'
error is happening at myArray![indexPath.row]
My function is meant to remove a String
value from myArray
, so I'm not sure how to resolve this error.
I appreciate any help/guidance!
Upvotes: 0
Views: 633
Reputation: 52416
arrayRemove
takes an array of values to be removed, you you'd want to use:
.arrayRemove([myArray![indexPath.row]])
See the added brackets
(https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array)
That being said, be aware that you're force unwrapping multiple things with !
-- be aware that if one of these values is nil
, your program will crash.
Upvotes: 2