swift - Swift 文本字段参数
问题描述
你好我刚开始学swift,我正在尝试创建一个函数
func dataStoroge(dataStoreName:UITextField,dataStoregaForKey:String,forEntityName:String) {
let appDelegate=UIApplication.shared.delegate as! AppDelegate
let context=appDelegate.persistentContainer.viewContext
let newUser=NSEntityDescription.insertNewObject(forEntityName: forEntityName, into: context)
newUser.setValue(dataStoreName, forKey: dataStoregaForKey)
do {
try context.save()
print("success")
}
catch{
print("error")
}
}
下面是我使用该功能的地方
let newUser=dataProcessors()
newUser.dataStoroge(dataStoreName: mailTextField, dataStoregaForKey: "mail", forEntityName: "UserInformation")
我想从文本字段中获取数据,但我不知道要使用哪个参数。你能帮助我吗?
解决方案
推荐阅读
- javascript - 对象中的基元更新但对象中的数组不更新
- html - 不再缩略图博客文章
- apache-spark - get_json_object 与 from_json 的性能
- java - Spring Boot 和 Spring Security,无法在 AuthenticationEntryPoint 中使用自定义消息发送错误
- haskell - /lib64/libtinfo.so.5:没有可用的版本信息
- python - 如何为 PyJulia 简化一串可执行代码
- c - 我在这里到底做错了什么?
- sql - 将where条件中的子查询列检索到主查询时出错
- powershell - powershell:将电话号码启动到默认 voip 程序
- c# - ASP.NET MVC 5:如何从 3rd 方库中禁用自定义错误页面