Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 错误:NSCFData辞职FirstResponder-无法识别的选择器已发送到实例。但是为什么呢?_Iphone_Memory Management_Memory Leaks - Fatal编程技术网

Iphone 错误:NSCFData辞职FirstResponder-无法识别的选择器已发送到实例。但是为什么呢?

Iphone 错误:NSCFData辞职FirstResponder-无法识别的选择器已发送到实例。但是为什么呢?,iphone,memory-management,memory-leaks,Iphone,Memory Management,Memory Leaks,我将NSCFData resignFirstResponder-无法识别的选择器发送到实例。但是为什么呢 @interface { UITextField *Field; } @end @implementation -(BOOL) textFieldShouldBeginEditing:(UITextField*)textField { Field = textField; return YES; } -(void) viewWillDisappear:(BOOL)anima

我将NSCFData resignFirstResponder-无法识别的选择器发送到实例。但是为什么呢

@interface { UITextField *Field; } @end
@implementation
-(BOOL) textFieldShouldBeginEditing:(UITextField*)textField {
    Field = textField;
    return YES;
}

-(void) viewWillDisappear:(BOOL)animated
{
    [Field resignFirstResponder];
}
@end
我的调用堆栈

0 CoreFoundation 0x35f08c7b __exceptionPreprocess + 114 1874 1 libobjc.A.dylib 0x30186ee8 objc_exception_throw + 40 1875 2 CoreFoundation 0x35f0a3e3 -[NSObject(NSObject) doesNotRecognizeSelector:] + 98 1876 3 CoreFoundation 0x35eaf467 ___forwarding___ + 506 1877 4 CoreFoundation 0x35eaf220 _CF_forwarding_prep_0 + 48 1878 5 MegaDish 0x000187eb -[MapViewController viewWillDisappear:] + 34 1879 6 UIKit 0x3389d438 -[UINavigationController viewWillDisappear:] + 112 0 CoreFoundation 0x35f08c7b例外预处理+114 1874 1 libobjc.A.dylib 0x30186ee8 objc_异常_抛出+40 1875 2 CoreFoundation 0x35f0a3e3-[NSObject(NSObject)未识别选择器:+98 1876 3 CoreFoundation 0x35eaf467 uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu+506 1877 4 CoreFoundation 0x35eaf220\u CF\u转发\u准备\u 0+48 1878 5 MegaDish 0x000187eb-[MapViewController视图将消失:][34 1879 6 UIKit 0x3389d438-[UINavigationController视图将消失:][112
您的文本字段被释放,可能在
-viewDidUnload
中。然后在内存中的同一位置分配一个
NSData
对象。执行
-textfielddidediting:
并将
字段
清除为
nil
,问题应得到解决。

您的文本字段已被释放,可能在
-viewdideunload
中。然后在内存中的同一位置分配一个
NSData
对象。执行
-textfielddidediting:
并将
字段清除为
nil
,这个问题应该得到解决。

大概你需要保留字段。

大概你需要保留字段。

替代@Jonathan的答案是,当你拥有文本字段时保留它,当你完成时释放它


另请注意:objective-c中的变量通常以小写字母开头。类名以大写字母开头。

替代@Jonathan的答案是,当您拥有文本字段时保留它,当您完成时释放它


另请注意:objective-c中的变量通常以小写字母开头。类名以大写字母开头。

首先,系统调用viewwill将消失,然后才调用viewDidUnload。我说得对吗?是的,但它可能会调用
-viewwilldiscover:
-viewDidUnload
-viewDidLoad
-viewwilldiscover:
,最后再次调用
-viewwilldiscover:
。关键是你没有正确地管理你的内存,结果你的指针坏了。首先,系统调用viewwill会消失,然后viewDidUnload。我说得对吗?是的,但它可能会调用
-viewwilldiscover:
-viewDidUnload
-viewDidLoad
-viewwilldiscover:
,最后再次调用
-viewwilldiscover:
。关键是你没有正确地管理你的内存,结果你的指针坏了。