如何使用 Core Data 在 UITextfield 中设置整数?
我可以在我的托管对象中设置文本,如下所示...
[editedObject setValue:textField.text forKey:editedFieldKey];
但我无法设置此...
[editedObject setValue:numberField.text forKey:editedFieldKey];
在 XCode 模板中,我可以将其直接设置到托管对象中,但像这样...
setValue:[NSNumber numberWithInt:200] forKey:@"jCode"];
但我似乎无法设置它通过 UITextField...请有人指出我正确的方向...它将受到高度赞赏...
I can set text in my managed object like this...
[editedObject setValue:textField.text forKey:editedFieldKey];
but I can't set this...
[editedObject setValue:numberField.text forKey:editedFieldKey];
In the XCode Template I can set this straight into the Managed Object but like this...
setValue:[NSNumber numberWithInt:200] forKey:@"jCode"];
but I can't seem to set it via a UITextField... Please can someone point me in the right direction... It will be highly appriciated...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能不想在标头中创建实例变量。您可以简化实现并在一行中提供
(id)value
。You likely don't want to create an instance variable in the header. You can simplify your implementation and provide an
(id)value
all in one line.感谢Eminatas...
我所做的第一件事是在我的头文件中添加一个int..
然后在我的implimentation中添加这个
然后像这样编辑管理对象...
感谢您为我指明了正确的方向...
Stef:-)
Thanx Eminatas...
1st what I did is in my header file add an int..
Then in my implimentation, added this
Then edited up managedObject like this...
Thanx for pointing me in the right direction...
Stef :-)
使用
[numberField integerValue]
从文本字段获取整数。use
[numberField integerValue]
to get integer from textfield.