Type mismatch issue while adding to coredata array

隐身守侯 提交于 2019-12-12 04:59:33

问题


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)!

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''

where Category is the entity name.

So how can I solve this issue...?


回答1:


Replace this line:

self.people.append(category)

From:

self.people.append(category.alertTextFieldData!)


来源:https://stackoverflow.com/questions/46338455/type-mismatch-issue-while-adding-to-coredata-array

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!