getting the object passed to the NSThread selector

前端 未结 2 708
南方客
南方客 2021-01-07 16:03

When I\'m creating an NSThread I pass it a number that I want the process to be aware of. I can understand how to set the number but I cannot figure out how to read the numb

2条回答
  •  -上瘾入骨i
    2021-01-07 16:23

    You're specifying your selector wrong:

    @selector(startTimerThread)   // we are missing ':' at the end
    

    It should have : at the end, like so:

    @selector(startTimerThread:) 
    

    This indicates it's a selector which takes one parameter.

    Then take in the parameter in your startTimerThread method:

    -(void) startTimerThread:(NSNumber *)myNumber {
        // ... etc
    

提交回复
热议问题