iOS performSelectorOnMainThread with multiple arguments

对着背影说爱祢 提交于 2019-12-02 17:53:12

When you're using iOS >= 4, you'd do this instead:

dispatch_async(dispatch_get_main_queue(), ^{
    [self doSomething:1 b:2 c:3 d:4 e:5];
});

That's like doing waitUntilDone:NO. If you want to wait until the method is finished, use dispatch_sync instead.

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 ];

you can pass one object of NSDictionary/NSArray type having required arguments.

and accept the same type of object in your function. then, decompose the values and proceed with processing.

you have to use NSNumber for numeric values for adding them to NSarray/NSDictionary and later on in your function, you can convert them back with intValue/floatValue etc

best of buck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!