I have a Cocoa interface. When I press a button I want to process some data, but I want to keep using the interface while it's working. I guess the only solution is NSThread. Now will there be a locking mechanism preventing me from returning from an IBAction method if it spawns a thread?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How to let a thread communicate with another activ
- back button text does not change
- iOS (objective-c) compression_decode_buffer() retu
相关文章
- 现在使用swift开发ios应用好还是swift?
- TCC __TCCAccessRequest_block_invoke
- xcode 4 garbage collection removed?
- Difference between Thread#run and Thread#wakeup?
- Java/Spring MVC: provide request context to child
- Unable to process app at this time due to a genera
- Threading in C# , value types and reference types
- How can I add media attachments to my push notific
Don't know much about cocoa, but starting a new thread for processing something in background while keeping the UI thread free for taking user inputs(and thus preventing UI from freezing) is the most widely used technique for the problem you have mentioned.Both threads will work together (concurrently) and the programmer has to take care of the synchronization issues if any.You should go ahead with the technique without doubt.
Thanks, Sourabh
Take a look at
NSOperation
.NSOperation
is one of the few cocoa classes which must be subclassed for it to be useful. By adding adelegate
property to yourNSOperation
subclass you can get notified when the operation completes. Also, you can add auserInfo
property to allow the operation to pass back arbitary data to the delegateNo, there is no locking mechanism. The new thread will start and the current thread will continue. You may want to look at
performSelectorInBackground:withObject:
and possiblyNSOperation
in addition toNSThread
.