开发者

In IPhone How to use multithreading with static methods in NSThread

开发者 https://www.devze.com 2023-01-11 09:03 出处:网络
I an developing an iPhone application in that,I am trying to download multiple files simultaneously from ftp server with threads.but my method to download is written in header file and that method is

I an developing an iPhone application in that,I am trying to download multiple files simultaneously from ftp server with threads.but my method to download is written in header file and that method is static.so if i try to access that method with to threads then variables of method for fir开发者_StackOverflow社区st thread are overridden by variables of first thread.Please suggest me how to synchronize the two threads in this case.


I was suffering from the same problem and i solved it by using code like this

Where you are telling the target for dedatching the method to thread you should use [Myclass class]

Example:

[NSThread detachNewThreadSelector:@selector(startSpinner) toTarget:[MyappDelegate class] withObject:nil];

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号