添加到 coredata 数组时键入不匹配问题 [英] Type mismatch issue while adding to coredata array
本文介绍了添加到 coredata 数组时键入不匹配问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经将 alertview 文本字段中的数据添加到 coredata 的对象中,就像这样......
I have added the data in an alertview textfield to the object of coredata like so...
let category = Category(context: self.context)
category.alertTextFieldData = (alertController.textFields?.first?.text)!
但现在我想将它添加到一个 CoreData 数组中,我正在尝试这样做...
But now I wanted to add this to a CoreData Array which I am trying to do like this...
self.people.append(category.alertTextFieldData!)
但是当我这样做时,它给出了错误..
But when I do this, it gives the error..
'Cannot convert value of type 'String' to expected argument type 'Category''
其中 Category
是实体名称.
那么我该如何解决这个问题...?
So how can I solve this issue...?
推荐答案
替换这一行:
self.people.append(category)
来自:
self.people.append(category.alertTextFieldData!)
这篇关于添加到 coredata 数组时键入不匹配问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文