How do I call performSelectorOnMainThread: with an selector that takes > 1 arguments?

前端 未结 3 974
不知归路
不知归路 2021-01-30 15:19

A typical call to performSelectorOnMainThread: looks like this:

[target performSelectorOnMainThread:action withObject:foo waitUntilDone:NO];
         


        
3条回答
  •  迷失自我
    2021-01-30 15:55

    You can do it by putting your args in a dictionary or array and passing that to a special function

    - (void)doStuff:(NSString *)arg1 and:(NSString *)arg2 and:(NSString *)arg3 {
    ...
    }
    
    - (void)doStuff:(NSArray *)argArray {
        [self doStuff:[argArray objectAtIndex:0]
                  and:[argArray objectAtIndex:1]
                  and:[argArray objectAtIndex:2];
    }
    

提交回复
热议问题