Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
Objective c 限制将对象添加到performSelector请求(iOS4)_Objective C_Ios4 - Fatal编程技术网

Objective c 限制将对象添加到performSelector请求(iOS4)

Objective c 限制将对象添加到performSelector请求(iOS4),objective-c,ios4,Objective C,Ios4,如果我使用此代码,则应用程序可以工作: if ([self.navigationController respondsToSelector:@selector(showUpdateRecordModalWithFrontWord:andBackWord:)]) { NSLog(@"seems to respond"); [self.navigationController performSelector:@selector(showUpdateRecordModa

如果我使用此代码,则应用程序可以工作:

if ([self.navigationController respondsToSelector:@selector(showUpdateRecordModalWithFrontWord:andBackWord:)]) {
        NSLog(@"seems to respond");
        [self.navigationController performSelector:@selector(showUpdateRecordModalWithFrontWord:andBackWord:) 
                withObject:[currentCard frontWord] withObject:[currentCard backWord]];


    }
如果我添加第三个参数(如下),我会得到一个SIGABRT

if ([self.navigationController respondsToSelector:@selector(showUpdateRecordModalWithFrontWord:andBackWord:andNotes:)]) {
        NSLog(@"seems to respond");
        [self.navigationController performSelector:@selector(showUpdateRecordModalWithFrontWord:andBackWord:andNotes:) 
                                        withObject:[currentCard frontWord] withObject:[currentCard backWord] withObject:[currentCard notes]];
    }
方法如下:

- (id)showUpdateRecordModalWithFrontWord:(NSString *)arg_name1 andBackWord:(NSString *)arg_name2 andNotes:(NSString *)arg_name3 {
    NSLog(@"%s", __FUNCTION__);

    AppProductModalController *modal = [[AppProductModalController alloc] initWithNibName:nil bundle:nil];
    [modal setNewRecord: NO];
    [modal setDelegate: self.topViewController];
    [modal.navBar.topItem setTitle: @"Update Card"];
    [modal.frontWordField setText: arg_name1];
    [modal.backWordField setText: arg_name2];
    [modal.notesField setText: arg_name3];
    [self presentModalViewController:modal animated:YES];
    [modal release];
    return nil;
}
我是否遇到了参数限制,或者我只是做错了什么


非常感谢您的帮助。

NSObject仅定义
性能选择器:
性能选择器:withObject:
性能选择器:withObject:withObject:
。在“添加对象”的幕后没有什么神奇之处,只是没有像
performSelector:withObject:withObject:withObject:withObject:
这样的方法。最好的解决方案可能是直接发送消息,而不是通过
performSelector:
。选择器不会变化,因此不会出现问题。

NSObject仅定义
性能选择器:
性能选择器:withObject:
性能选择器:withObject:withObject:
。在“添加对象”的幕后没有什么神奇之处,只是没有像
performSelector:withObject:withObject:withObject:withObject:
这样的方法。最好的解决方案可能是直接发送消息,而不是通过
performSelector:
。选择器没有变化,因此应该不会有问题。

为什么要发送
-performSelector…
而不是直接发送消息?例如,
[self.navigationController显示UpdateRecordModal with frontWord:[currentCard frontWord]和backWord:[currentCard backWord]]为什么要发送
-performSelector…
而不是直接发送消息?例如,
[self.navigationController显示UpdateRecordModal with frontWord:[currentCard frontWord]和backWord:[currentCard backWord]]“您最好的解决方案可能是直接发送邮件”谢谢!大卫·德尔蒙特:正如巴瓦奇在他的评论中所写的那样,类似于
[self.navigationController show updaterecordmodal with frontWord:[currentCard frontWord]和backWord:[currentCard backWord]]
的东西应该可以用。您可能需要强制转换导航控制器以避免收到警告,但这是一个基本的消息发送。明白了。谢谢我没有看到巴顿的留言。。自我提示>学会阅读。“也许你最好的解决办法就是直接发送信息”谢谢!大卫·德尔蒙特:正如巴瓦奇在他的评论中所写的那样,类似于
[self.navigationController show updaterecordmodal with frontWord:[currentCard frontWord]和backWord:[currentCard backWord]]
的东西应该可以用。您可能需要强制转换导航控制器以避免收到警告,但这是一个基本的消息发送。明白了。谢谢我没有看到巴顿的留言。。自我提示>学习阅读。