简体   繁体   English

NSInvalidArgumentException原因:无法识别的选择器发送到实例

[英]NSInvalidArgumentException reason : unrecognized selector sent to instance

I wanted to contribute something back, since everyone here has been so responsive. 我想回馈一些东西,因为这里的每个人都反应迅速。 I was getting the above error on an action "button". 我在操作“按钮”上遇到了以上错误。 It was driving me crazy. 这让我发疯。 You see I have a master/detail template and I added an extra detail view to my project. 您会看到我有一个主/详细模板,并且在项目中添加了一个额外的详细信息视图。 I had a button on the second detail view, but not on the first. 我在第二个详细视图上有一个按钮,但在第一个没有。 I took all of the code out of the button action and still received the error, so I added the same button to the first detail view ... and what do you know it worked. 我从按钮操作中取出了所有代码,仍然收到错误,因此我将相同的按钮添加到了第一个详细信息视图中……您知道它的作用是什么。

-(IBAction) addData_btn: (sender){

    NSMutableArray *array = [[NSMutableArray alloc] init];

    [array addObject:AcctName.text];
    [array addObject:AcctNum.text];
    [array addObject:DayDue.text];
    [array addObject:paymnt.text];
    [array addObject:remBalance.text];

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);

    NSString *documentPath = [paths objectAtIndex:0];

    NSString *plistPath = [documentPath stringByAppendingPathComponent:@"Accounts.plist"];

    [array writeToFile:plistPath atomically: true];
}

I added same button to first detail view, without any code ... it worked. 我在第一个详细信息视图中添加了相同的按钮,而没有任何代码...它起作用。

Make sure that, on Interface Builder, you didn't left any connections on buttons to actions that do not exist on their correspondent ViewControllers. 确保在Interface Builder上,您没有在按钮上留下任何与其对应的ViewController上不存在的动作的连接。 Or else, the button, when touched, will try to call a method that doesn't exists, throwing this exception. 否则,当按钮被触摸时,将尝试调用不存在的方法,并引发此异常。

if your issue is happening where you have more than one detailViewControllers ... add same button or fields to the other detailViewcontroller. 如果您的问题发生在您有多个detailViewControllers的地方,请向其他detailViewcontroller添加相同的按钮或字段。 it should take care of issue. 它应该照顾的问题。 Good Luck 祝好运

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NSInvalidArgumentException,原因无法识别的选择器发送到实例 - NSInvalidArgumentException, reason unrecognized selector sent to instance MDC 因“NSInvalidArgumentException”而崩溃,原因:“-[UIButton applyOutlinedThemeWithScheme:]: 无法识别的选择器发送到实例 - MDC crashing with 'NSInvalidArgumentException', reason: '-[UIButton applyOutlinedThemeWithScheme:]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[__ NSCFString encodeString:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString encodeString:]: unrecognized selector sent to instance 未捕获的异常'NSInvalidArgumentException',原因: - [_ SwiftValue floatValue]:无法识别的选择器发送到实例 - Uncaught exception 'NSInvalidArgumentException', reason: -[_SwiftValue floatValue]: unrecognized selector sent to instance NSInvalidArgumentException',原因:' - [__ NSArrayI length:无法识别的选择器发送到实例 - NSInvalidArgumentException', reason: '-[__NSArrayI length : unrecognized selector sent to instance 异常'NSInvalidArgumentException',原因:'-[AnnotationView setCoordinate:]:无法识别的选择器已发送到实例 - exception 'NSInvalidArgumentException', reason: '-[AnnotationView setCoordinate:]: unrecognized selector sent to instance NSInvalidArgumentException',原因:' - [UITableView setSeparatorInset:]:发送到实例的无法识别的选择器 - NSInvalidArgumentException', reason: '-[UITableView setSeparatorInset:]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[__ NSCFString objectAtIndex:]:无法识别的选择器已发送到实例 - 'NSInvalidArgumentException', reason: '-[__NSCFString objectAtIndex:]: unrecognized selector sent to instance 'NSInvalidArgumentException',原因:'-[REAEventDispatcher setBridge:]: 无法识别的选择器发送到实例 - 'NSInvalidArgumentException', reason: '-[REAEventDispatcher setBridge:]: unrecognized selector sent to instance NSInvalidArgumentException',原因:'-[NSNull 长度]:无法识别的选择器发送到实例 - NSInvalidArgumentException', reason: '-[NSNull length]: unrecognized selector sent to instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM