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
0
votes
1 answer

lighter way for inter-thread communication than performSelector:onThread:withObject

I was testing performSelector:onThread:withObject:waitUntilDone: for inter-thread communication as recommended by Matt Ghallagher's tutorial. Turns out that it is extremely slow, and pretty much no good for real time audio applications. Any…
abbood
  • 23,101
  • 16
  • 132
  • 246
0
votes
0 answers

NSTimer in Cocoa (MAC) app

I am working on a timer application where i have used 5-6 timers running at one time, I need all the timers running at the same time. For ex. calculating a time, updating the UI etc. But this is hangs my app, After some time, its started not…
york
  • 149
  • 1
  • 11
0
votes
1 answer

performSelector:OnThread:waitUntilDone not executing the selector all the time

I have an app where the network activity is done in its separate thread (and the network thread continuously gets data from the server and updates the display - the display calls are made back on the main thread). When the user logs out, the main…
R.S
  • 321
  • 3
  • 15
0
votes
1 answer

Lock and then Unlock Code for a while

I am using CLLocationManager and CLLocationManagerDelegate to find out user location coordinates. I would like to make sure that I have got my coordinate first and then resume the rest of code. How could I able to lock my code to get location…
user1724168
0
votes
0 answers

NSTimer vs NSThread to make recursive calls using AFNetworking

My basic requirement is to poll the server every 5 seconds and fetch some data. This activity should not freeze/affect the UI in anyway. The data would make minor updates to the UI. The calls made to the server are made using AFNetworking. I would…
Peyush Goel
  • 383
  • 2
  • 3
  • 13
0
votes
1 answer

How to stop current running thread

I am creating new thread on one button click On other button click i want to stop that thread How to implement it... I have used [NSThread exit]; but it freezes my UI.....
0
votes
2 answers

cocos2d-iphone action is interrupted by ongoing operations

I want to run an action and go on go on processing game logic at the same time, but action is interrupted when the process is going on. I tried to use thread, but I couldn't make it work. When it's not needed to process game logic the sprites move…
beyax
  • 27
  • 2
0
votes
2 answers

"Thread 1: Signal SIGARBT" Error When Running in Simulator

I'm pretty new to this, but when I try to simulate on the iOS simulator it stops and then this error pops up...I added a View Controller for my a table view in my storyboard. I will include the file so you guys have enough info to help me out. Im…
drfear
  • 121
  • 1
  • 7
0
votes
1 answer

How to wake up thread after [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:distantFuture]?

I have a Download object which handles NSURLConnection. Then I have NSOperation object (DownloadOperation) which holds Download object as property. Download object has ability to start/pause/resume/cancel. This is the main method of…
vale4674
  • 4,161
  • 13
  • 47
  • 72
0
votes
2 answers

performSelectorInBackground causes random crash when view is dismissing

I'm having some random crashes at this part of my code: -(void) goBack { [self performSelectorInBackground:@selector(addActivityIndicator) withObject:nil]; [self.navigationController popViewControllerAnimated:YES]; } -…
Rafael
  • 1,655
  • 3
  • 17
  • 25
0
votes
2 answers

SHowing Activity Indicator View Using Thread Shows This Error in gdb?

i m using this on uitableviewcell's didselectrow method [NSThread detachNewThreadSelector:@selector(showMyWaitView) toTarget:self withObject:nil]; it works fine but it shows error in gdb like this 2009-08-10 12:45:01.313 FlashCards[1209:6307] *…
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
0
votes
1 answer

threading for network calls in iOS 5

I have been looking over the internet, but could not find the perfect tutorial for threading in iOS, currently i am working on iOS 5 , tutorial found on web were old, my app needs to fetch data from webservices, so I want to call network operation…
Raheel Sadiq
  • 9,847
  • 6
  • 42
  • 54
0
votes
1 answer

Exit a NSThread when it's sleeping?

I am creating a new Thread which runs one of my method: Now what i am doing is as follows: NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(myThreadFunc) object:nil]; [thread start]; in myThreadFunc { …
The Bird
  • 397
  • 2
  • 8
  • 19
0
votes
1 answer

NSThread and events

I use something similar to android toast to send messages to the user. This toast is shown in the current view, in this case I want to change the view, and there is no time to read the message. So, I use a thread to stay in the current view for 3…
user1256477
  • 10,763
  • 7
  • 38
  • 62
0
votes
0 answers

AVAudioPlayer thread instansiate

The following code gives me an exception with the title on the line of the alloc of AVAudioPlayer: thread 1 breakpoint 1.2 Do I make a mistake in instantiating the AVaudioPlayer? Or is the problem cause by the fact that the player plays on a…
YoYoHu
  • 92
  • 1
  • 11