[英]Cannot convert value of type '[String : Any]' to expected argument type 'String'
[英]Cannot convert value of type 'String' to expected argument type '[Any]'
我在cellForRowAt
方法中收到以下代碼錯誤:
self.db.collection("myCollection").document(self.currentUser!).updateData(["myArray":FieldValue.arrayRemove(myArray![indexPath.row])]).
Cannot convert value of type 'String' to expected argument type '[Any]'
錯誤發生在myArray.[indexPath.row]
我的 function 是為了從myArray
中刪除一個String
值,所以我不知道如何解決這個錯誤。
我感謝任何幫助/指導!
arrayRemove
需要一個要刪除的值數組,你想使用:
.arrayRemove([myArray![indexPath.row]])
請參閱添加的括號
( https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array )
話雖如此,請注意您正在使用!
-- 請注意,如果這些值之一是nil
,您的程序將崩潰。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.