Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.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 在NSTimer的userInfo中传递整数_Objective C_Nstimer_Nsinteger - Fatal编程技术网

Objective c 在NSTimer的userInfo中传递整数

Objective c 在NSTimer的userInfo中传递整数,objective-c,nstimer,nsinteger,Objective C,Nstimer,Nsinteger,我正试图通过NSTimer的userInfo字段传递一个整数(testInt) timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(count:) userInfo:testInt repeats:YES]; 但是,我收到一条不兼容类型的错误消息 有人知道如何将数字传递到计数方法吗?您需要将其框到: userInfo应该是一个对象。 timer = [NSTimer schedul

我正试图通过
NSTimer的
userInfo
字段传递一个整数(
testInt

timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(count:) userInfo:testInt repeats:YES];
但是,我收到一条不兼容类型的错误消息

有人知道如何将数字传递到
计数方法吗?

您需要将其框到:


userInfo
应该是一个对象。
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 
                                         target:self 
                                       selector:@selector(count:) 
                                       userInfo:@(testInt)  // <-- @() around your int.
                                        repeats:YES];
int testInt = [timer.userInfo intValue];