Objective c NSTimer参数NSIndexPath

Objective c NSTimer参数NSIndexPath,objective-c,nstimer,Objective C,Nstimer,我想给出一个带有NSTimer的参数。 timertocallguest是在.h中制造的NSTimer timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(gettheguestyouaskedforTOTURNON) userInfo:nil repeats:YES]; 如何使用选择器传递参数? 在某些选择器上,我可以在其后面添加withObject以提供参数。。

我想给出一个带有NSTimer的参数。 timertocallguest是在.h中制造的NSTimer

timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1  target:self selector:@selector(gettheguestyouaskedforTOTURNON) userInfo:nil repeats:YES];
如何使用选择器传递参数? 在某些选择器上,我可以在其后面添加withObject以提供参数。。 但是我不能在这里这么做,我只想给我调用的函数一个nsindepath

有人能帮我吗?
您的通话中,选择器名称后没有冒号。应该是这样写的:

timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1  target:self selector:@selector(gettheguestyouaskedforTOTURNON:) userInfo:nil repeats:YES];
如果Xcode建议使用不带冒号的选择器,请确保您尝试调用的方法实际使用了一个参数(类型为
id
nsindepath*

编辑以回应评论:

对象(在本例中为myObject)需要作为userInfo传入,如下所示:

timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1  target:self selector:@selector(gettheguestyouaskedforTOTURNON:) userInfo:myOject repeats:YES];

我遇到了一个类似的问题,当我使用NSTimer从-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath调用一个方法时

可能的复制我能够使选择器没有collon,它正在工作。所以这是正确的方法-(void)gettheguestyouaskedforTOTURNON:(NSIndexPath*)使用NSTimer timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1目标:自选择器:@selector(gettheguestyouaskedforTOTURNON:selectedIndexPath)用户信息:无重复:是];嗯,我现在得到了这个,但我一直得到一个NSFCTimer错误-(void)gettheguestyouaskedforTOTURNON:(NSIndexPath*)therow{;timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1目标:自选择器:@selector(gettheguestyouaskedforTOTURNON:)用户信息:SelectedIndexPath repeats:YES];SelectedIndexPath是一个NSIndexPath对象,我使用它来获取行的索引。您能在这里发布整个错误消息吗?这可能会很有帮助…***由于未捕获的异常“NSInvalidArgumentException”,终止应用程序,原因:'-[\u NSCFTimer行]:无法识别的选择器发送到实例0x4b6b200'***第一次抛出时的调用堆栈:这就是您所需要的吗?我的操作与我告诉我的上一条注释完全相同如果消息发送到不理解的对象,则会出现这种错误(实现的方法)它有时是由于内存管理问题造成的。因此,我认为这与您的主要问题没有直接关系。在您遵循我的指示之前是否也发生过这种情况?