[英]How to save uipickerview data for core data in Swift?
There is one uipickerview in a single view application. 单视图应用程序中有一个uipickerview。 The user selects a name by click on a uibutton. 用户通过单击uibutton选择名称。
To be more specific 更加具体
So, how to get the data from the uipickerview for coredata in iOS Swift application? 那么,如何在iOS Swift应用程序中从uipickerview获取coredata的数据呢?
You can set your class as picker view delegate throught delegate property on picker view. 您可以通过选择器视图上的委托属性将类设置为选择器视图委托。 Your class should conform to the UIPickerViewDelegate protocol, and implement method 您的类应符合UIPickerViewDelegate协议,并实现方法
optional func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)
you got row
parametr here and you can just pick up the related data. 您在此处获得了row
参数,您只需提取相关数据即可。 Then you can easily save it to core data. 然后,您可以轻松地将其保存到核心数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.