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

Image view not updating on NSThread

I'm trying to make a test app which measures the performance for threads. However, I'm trying to set an image to imageview on a thread and it's not updating. In fact, the methods setImage1 and setImage2 aren't even getting called. Any ideas? Look at…
tadejsv
  • 2,085
  • 1
  • 18
  • 20
3
votes
3 answers

NSTimer or NSThread in iOs 4 background mode

I have to keep a NSThread or NSTimer when my iPhone application goes into background mode. Is it possible ? I have enabled the background modes in info.plist and opened readstream and writestream as follows ...(I am using…
S.P.
  • 5,427
  • 11
  • 56
  • 83
3
votes
2 answers

UIProgressView progress doesn't updated

I have a UIProgressView added to self.view as subview. I have a UITableView with rows loaded. I need image in every row but I don't want the app to wait for all of them, so I decide to run NSThread with loading images process. When I try to update…
Artem Svystun
  • 179
  • 1
  • 14
3
votes
3 answers

iOS: how to properly stop an Activity Indicator?

I'd like to stop the animation of the indicator within a method called by default NSNotificationCenter with a postNotificationName. So I'm doing this on Main Thread -(void)method { ... [ind…
user3290180
  • 4,260
  • 9
  • 42
  • 77
3
votes
1 answer

NSOperations or NSThread for bursts of smaller tasks that continuously cancel each other?

I would like to see if I can make a "search as you type" implementation, against a web service, that is optimized enough for it to run on an iPhone. The idea is that the user starts typing a word; "Foo", after each new letter I wait XXX ms. to see…
RickiG
  • 11,380
  • 13
  • 81
  • 120
3
votes
0 answers

UIActivityIndicatorView stop animating after minimize app and resume app?

I have an upload method which uploads audio with some other data. Uploading task gets more time. At the starting of this method I start an UIActivityIndicator using NSThread class method. UIActivityIndicator starts animating. But my problem is…
user4276168
3
votes
2 answers

Any way to make dispatch_queue_t work in single thread?

Here is my code: @interface MyObject () @property(nonatomic) dispatch_queue_t queue; @end @implementation MyObject { NSThread *_check; } - (id)init { self = [super init]; if (self) { _queue =…
Kirow
  • 1,077
  • 12
  • 25
3
votes
2 answers

dispatch_queue_t is serial queue then why does it even exists in multi-task concept?

I am newer to iPhone development and going through GCD concept for multithreading. 'dispatch_queue_t' creates a serial queue and I have read that a serial queue will only execute one job at a time. GCD is intended to execute multiple tasks…
NSPratik
  • 4,714
  • 7
  • 51
  • 81
3
votes
0 answers

NSRunLoop from a queue context does it make sense?

I've been trying to move away from targeting specific threads and thinking more about queues like suggested by best practices and guidelines in the iOS arena. WHAT I USED TO DO: I used to be able to create a new thread, then run a runloop on…
zumzum
  • 17,984
  • 26
  • 111
  • 172
3
votes
2 answers

iPhone: One Object, One Thread

On the iPhone, I would like to do some operations on an image in a separate thread. Rather than dealing with semiphores, locking, etc., I'd like to use the 'One Object, One Thread' method of safely writing this concurrent operation. I'm not sure…
GingerBreadMane
  • 2,630
  • 1
  • 30
  • 29
3
votes
4 answers

Execute function every X minutes in background doesn't work

I use this code to execute function every X minutes: - (void)executeEveryOneMinute { [self myFunction]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self…
1110
  • 7,829
  • 55
  • 176
  • 334
3
votes
4 answers

calling method repeatedly after 3 seconds time interval in background

I have gone through many sites but still no answer. I have a method suppose void xyz(), which will get called automatically from a View Controller after every 3 seconds. I have no idea what to use, do I have to use NSThread or PerformSelector.
Vizllx
  • 9,135
  • 1
  • 41
  • 79
3
votes
2 answers

How to use [performSelector: onThread: withObject: waitUntilDone:]?

I tried to subclass NSThread in order to operate a thread with some data. I want to simulate the join() in python, according to the doc: join(): Wait until the thread terminates. This blocks the calling thread until the thread whose join()…
Kun Hu
  • 417
  • 5
  • 11
3
votes
2 answers

setbackground loading with do while loop

i am working on an application where i check for url using following code. -(void)exists { NSString *strImg = @"some url"; NSURL *aImgUrl = [NSURL URLWithString:strImg]; NSMutableURLRequest *imgRequest = [NSMutableURLRequest…
3
votes
3 answers

Running NSTimer on a thread

I am trying to run a NSTimer on a thread using iPhone SDK 3.0. I think I am doing everything correctly (new runloop etc.). If I call [timer invalidate] on viewDidDissappear though I get this error: bool _WebTryThreadLock(bool), 0x3986d60: Tried to…
John
  • 33
  • 1
  • 3