Can i call a NSThread function detachNewThreadSelector: toTarget: withObject: with 2 parameters?

折月煮酒 提交于 2019-12-12 01:15:23

问题


I want call a function which makes my main thread stuck using the above function so that it can run in a diff thread. But the problem is that my function have 2 parameters. Is it possible to do so?


回答1:


Simply pass as the object an NSDictionary built using all of the arguments needed by your function (can be even more than two using the dictionary).

In the code related to the function you pass as a selector, you then retrieve from the dictionary your arguments as the objects stored within the dictionary.



来源:https://stackoverflow.com/questions/2047676/can-i-call-a-nsthread-function-detachnewthreadselector-totarget-withobject-wi

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