iOS performSelectorOnMainThread with multiple arguments

后端 未结 3 1857
北荒
北荒 2021-02-01 01:46

I would like to perform a selector on the main thread from another thread, but the selector has multiple arguments, similar to this:

-(void) doSomethingWith:(int)

3条回答
  •  春和景丽
    2021-02-01 02:10

    You'll need to use a NSInvocation

    Create the object, set the target, selector and arguments.
    Then, use

    [ invocationObject performSelectorOnMainThread: @selector( invoke ) withObject: nil, waitUntilDone: NO ];
    

提交回复
热议问题