Questions tagged [nsthread]

`NSThread` is part of the Objective-C Foundation Framework and provides developers a way to create and manage threads.

An instance of NSThread controls a thread of execution. Developers can use this class when they would like to perform a series of tasks in its own thread of execution. An example is if the developer wanted to have an Objective-C method run in its own thread of execution.

Threads are useful for long-running tasks that avoid blocking the main thread of the application (where user interface and event-related tasks are handled), as well as dividing a large task into several smaller sub-tasks. This can lead to performance improvements.

In GNUStep, NSThread essentially encapsulates OpenStep threading. Each process starts with a main thread and additonal threads can be created by using NSThread. The GNUStep implementation of OpenStep was designed so that the internals of the base library do not use threading (except in the case of methods that explicitly deal with threads). This makes it possible to write applications without any sort of threading.

References

729 questions
2
votes
1 answer

StatusItem menu blocks main thread when it's opened. Workaround?

I've written an app for the Mac that is designed as a status bar item. However, when a user opens its menu from the status bar, the main run loop is blocked until it's closed. Since this app responds to messages on a socket, it's a problem that it…
Moduspwnens
  • 525
  • 1
  • 5
  • 9
2
votes
3 answers

NSRunLoops in Cocoa?

Let's say I have 2 threads, one is the main thread and another one, a secondary thread. The main thread is being used the most, but sometimes (rarely) I want the secondary thread to do some work based on calls from the main thread. Most of the time…
Alex1987
  • 9,397
  • 14
  • 70
  • 92
2
votes
0 answers

iPhone upload in new thread

I've been trying to implement a background thread in my app to do the long haul, hard graft uploading stuff. I'm using the FBConnect SDK and it has been working perfectly but I would like to keep the GUI side working smoothly and at the moment there…
Fogmeister
  • 76,236
  • 42
  • 207
  • 306
2
votes
1 answer

Call a delegate's method within a background

this is my first question here, so excuse me if I made any mistakes! In my iPhone project I have a method running in a thread which takes a long time to execute (that's why it runs in a thread). [NSThread…
Sebastian Wramba
  • 10,087
  • 8
  • 41
  • 58
2
votes
0 answers

Does the waiting selectors of NSThread accessible?

I have on many places in my code: [self performSelector:@selector(mySelector:) onThread:myThread withObject:nil waitUntilDone:YES]; I want to know how many selectors are waiting to be performed in myThread. Is it possible?
EdiZ
  • 441
  • 4
  • 13
2
votes
3 answers

How to update a UILabel frequently?

I am currently working on a project where I request and parse multiple html sites in a controller. To give some feedback to the user I have created a second view, which gets displayed during processing of the data. It displays a status label and a…
jagse
  • 333
  • 4
  • 18
2
votes
2 answers

Reachability problem with notifications on a separate thread

I make use of Apples Reachability class and it works if I keep it on the main thread(bad approach). If I instead move it to a separate thread the notification is never called. In didFinishLaunchingWithOptions i call the following: [NSThread…
mbogh
  • 1,361
  • 11
  • 28
2
votes
0 answers

Monotouch PerformSelector on specific thread with multiple arguments and callbacks

I've been having some issues with threading in monotouch. My app makes use of an external library which I've linked with and it works fine. Because of the nature of the app and the library I have to make all the calls to it on a single separate…
2
votes
2 answers

Coredata performBlock then return the new value

How to return the new object saved in coredata if I am using performBlock to save a managedObjectContext? The requirement is, add an entry in coredata, and return it. My code is something like this: //create a privateMOC NSManagedObjectContext…
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
2
votes
4 answers

Circular Progress bar on ImageView using SDWebImage block

I am trying to implement a instagram like circular progress bar for image loading using SDWebImage. 1.I am using this piece of code but it is not working properly. The progress bar is not getting hidden after image is applied to the imageview. Cell…
Shikhar varshney
  • 816
  • 1
  • 9
  • 23
2
votes
0 answers

Xcode objective-c NSThread arguments

I have a function that I need to run async in a separate thread however I couldn't figure out how to pass multiple arguments to the function so I decided to pass an array of arguments. There are two lines of code that I won't compile indicated with…
Jim Dandy BOA
  • 533
  • 7
  • 13
2
votes
2 answers

How to pass NSTimeInterval object to detachNewThreadSelector withObject parameter?

I'm still new to Objective C syntax, so I might be overcomplicating this, but I can't seem to figure out how to pass an NSTimeInterval to a thread. I want to initiate a thread that sleeps for x seconds parameter sent from main thread as follows:…
Yousef
  • 21
  • 1
  • 2
2
votes
1 answer

IconDownloader,issue with lazy downloading

My problem is simple to be described but it seems to be hard to solve. The problem is loading icons, with a custom class like IconDownloader.m provided by an official example from Apple, avoiding crashes if I release the view. I've added the…
bontoJR
  • 6,995
  • 1
  • 26
  • 40
2
votes
1 answer

Delaying Code Execution on OSX 10.10

I've encountered a very strange issue that affects my code running only on OSX 10.10 systems. I've seen this anomaly occur on over 25 OSX 10.10 systems running my code, whereas the exact same code did not exhibit this behavior before upgrading…
Authman Apatira
  • 3,994
  • 1
  • 26
  • 33
2
votes
2 answers

What is wrong with my @synchronized block?

I have 2 threads in my application, a game update thread and render/IO/main thread. My update thread updates the game state, and the render thread renders the scene based on the updated values of the game state models and a few other variables…
Morrowless
  • 6,856
  • 11
  • 51
  • 81