我想给出一个带有NSTimer的参数。NSTimer NSTimer是在.h中制作的NSTimer;
timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(gettheguestyouaskedforTOTURNON) userInfo:nil repeats:YES];如何通过选择器传递参数?在一些选择器中,我可以在它后面添加withObject来给它提供参数。但我不能在这里做,我只想给我调用的函数一个NSIndexPath。
有谁能帮我吗?泰已经,
发布于 2011-05-23 15:37:50
您的呼叫在选择器名称后缺少冒号。它应该是这样的:
timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(gettheguestyouaskedforTOTURNON:) userInfo:nil repeats:YES];如果Xcode建议使用不带冒号的选择器,请确保您尝试调用的方法实际上接受了一个参数(类型为id或NSIndexPath*)。
回复评论的编辑:
该对象(在本例中为myObject)需要作为userInfo传入,如下所示:
timertocallguest=[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(gettheguestyouaskedforTOTURNON:) userInfo:myOject repeats:YES];发布于 2012-10-05 16:11:33
当我使用NSTimer从- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath调用方法时,我也遇到了类似的问题。
https://stackoverflow.com/questions/6094136
复制相似问题