Int or NSInteger as object for method argument. Objective-C

前端 未结 4 1001
独厮守ぢ
独厮守ぢ 2021-02-07 14:21

I\'m having some trouble passing a number as an argument for a method:

- (void)meth2:(int)next_int;

And to call that method I need this:

<
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-07 14:56

    You can't use next_int as the withObject: because it's not an Object.

    Change your call to:

    [self performSelectorOnMainThread:@selector(meth2:) 
          withObject:[NSNumber numberWithInt:next_int] waitUntilDone:NO];
    

    EDIT: And change meth2 to expect an NSNumber instead of an int.

提交回复
热议问题