在委托调用中丢失属性地址
你好,我正在使用一个 UITableViewController,它有一个 @property (retain,nonatomic) NSString* name;
,它是从以前的 ViewController 填充的。它有一个带有 delegate=self
的 UITextField 在 viewWillAppear 上我设置了该字段的文本。一切都工作得很好...
但是在 - (BOOL)textFieldShouldReturn:(UITextField *)textField
我得到了一个指向 self.name 的零指针
是否有一些我对线程不太了解的东西,所以这可以吗是问题的根源吗?
编辑:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
self.title = textField.text;
self.name = textField.text; //Brakepoint self.name == nil
[textField resignFirstResponder];
return NO;
}
Hi i'm using a UITableViewController which has a @property (retain,nonatomic) NSString* name;
which is filled from the previous ViewController. And it has a UITextField with a delegate=self
On viewWillAppear i set the text of the Field. All wonderfully working...
But in - (BOOL)textFieldShouldReturn:(UITextField *)textField
i got a nil-pointer to self.name
Is there something i don't know much about threads so could this be the source of the problem?
EDIT:
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
self.title = textField.text;
self.name = textField.text; //Brakepoint self.name == nil
[textField resignFirstResponder];
return NO;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从两个不同的 NavigationController 调用了 TableViewController。一个有效,另一个无效。我只在其中之一遇到了这个错误。对名称的引用来自另一个导航控制器......
I called the TableViewController from two different NavigationControllers. One worked the other didn't. I got the bug only at one of them. The reference to name was from the other NavigationController....