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
2 answers

Timing and repeating thread execution in Objective-C

I'm wondering if I'm able to time a thread to be executed repeatedly (like when using the scheduledTimerWithTimeInterval method in NSTimer).. I have a view controller, where there is a method I want it to be executed either manually (by clicking a…
ObjProg
  • 429
  • 1
  • 7
  • 19
2
votes
2 answers

NSAutoreleaseNoPool(): Object 0x66ad9d0 of class NSConcreteMutableData autoreleased with no pool in place - just leaking

I am trying to perform thread operation in my project. The things are getting worked but I am getting NSAutoreleaseNoPool(): Object 0x66ad9d0 of class NSConcreteMutableData autoreleased with no pool in place - just leaking pring on my NSLOG. My Code…
Kapil Choubisa
  • 5,152
  • 9
  • 65
  • 100
2
votes
1 answer

Correct usage of secondary NSThread with NSRunLoop

I have a performance-sensitive code, working with frames of video-playback in real time. I have some work here which can be parallelised and since it's a performance-sensitive code where latency is the key I decided to go with NSThread instead of…
Eugene Alexeev
  • 1,152
  • 12
  • 32
2
votes
0 answers

Increase stack_size in iOS test bundle

I'm trying to run unit tests, using XCTest, and I need to increase stack_size to 2MB. When linking an executable, using -Wl,-stack_size option, I can change it. First question, I'm not sure if this option applies to all threads, or only the main…
Gerald
  • 690
  • 4
  • 13
2
votes
2 answers

NSThread and updating objects in subviews

In my app I want to make un update of my database when I press a button. Because it takes some time for this job and not to freeze the hole app I decided to use NSThread. This process can be started from different views, so I have placed the…
CristiC
  • 22,068
  • 12
  • 57
  • 89
2
votes
1 answer

Objective C - performSelectorInBackground V.S detachNewThreadSelector?

Both detachNewThreadSelector and performSelectorInBackground are used to call a method in the background. Is there any difference between the 2 methods? or do they both work the same way?
aryaxt
  • 76,198
  • 92
  • 293
  • 442
2
votes
2 answers

Thread and NSTimer

I am making an application that has a timer. I count the minutes and seconds from a given time down to 0. When this happen I launch an alertview. My structure is this: Mainthread method allocate a new thread and initialize it. The entrypoint(method)…
LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
2
votes
3 answers

How to implement NSThread to constantly perform the function in background in iPhone SDK

In my iPhone app, I have to perform function constantly in background. For that I think I will have to use NSThread to call the function and keep it executing in background. I dont want to stall my app and hence I want to use NSThread to keep my…
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
2
votes
1 answer

Initializing UITextView in a thread -- Causing issue

When I am trying to execute in a thread: UITextView *aDescriptionView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, 25, 50)]; I am getting this error: bool _WebTryThreadLock(bool), 0x2819b0: Tried to obtain the web lock from a thread other…
Abhinav
  • 37,684
  • 43
  • 191
  • 309
2
votes
1 answer

secondary thread regarding

I have a main and an auxiliary thread in my app. Main thread as everyone knows is being used by UI. I use the secondary thread to do the background loading of my views. I have a main controller which i call a dummy controller. From there i call my…
swapnil
  • 43
  • 6
2
votes
2 answers

How to handle leaks when using a multiple threads in iphone?

I have called a method in separate thread in viewdidload method [NSThread detachNewThreadSelector:@selector(callWebService) toTarget:self withObject:nil]; -(void)callWebService{ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; …
Warrior
  • 39,156
  • 44
  • 139
  • 214
2
votes
3 answers

What is the best way to deal with UIActivityIndicator and multiple threads?

I have been trying to play around with this for a long time and I can't seem to find the best approach. I am getting confused because there seem to be different answers/opinions on how to accomplish this seemingly simple task. I want to be able to…
jschmidt
  • 2,898
  • 3
  • 24
  • 27
2
votes
2 answers

stopping a photo from a new thread to load

I'm loading images with this class. I need help on how to stop them from loading when dealloc is called. This class is extending UIImageView. Also any other advice for designing the class is appreciated, i'll want for example to dispatch the loaded…
Cristi Băluță
  • 1,295
  • 15
  • 27
2
votes
2 answers

How should this code be changed to work correctly?

I downloaded some code from http://github.com/matej/MBProgressHUD to show a progress meter when doing something. This is the code that makes the progress meter pop up. [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil…
node ninja
  • 31,796
  • 59
  • 166
  • 254
2
votes
1 answer

Exiting a NSThread to break out from an infinite loop without cancellation point

I am unsure if what I am trying to achieve is possible. I got a bug while rendering PDF pages into images, it seems that our application is encountering erroneous PDF documents sometime and some rendering are taking literally forever (never…
Béatrice Cassistat
  • 1,048
  • 12
  • 37