[英]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.