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

How to end a polling thread created with detachNewThreadSelector?

I'm creating a new thread using detachNewThreadSelector ref with toTarget self. The purpose of the thread is to poll movements and load images as appropriate - it loops and only quits when an atomic bool is set to true in the main thread - which is…
CiscoIPPhone
  • 9,457
  • 3
  • 38
  • 42
0
votes
1 answer

Searching Core Data in Background Thread, Function Terminate Randomly

This is my searching function: - (void)searchingMethod:(NSString *)aText{ NSManagedObjectContext *context = [self managedObjectContext]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Entity"…
Jimi
  • 1,091
  • 1
  • 14
  • 19
0
votes
1 answer

iOS loading animation not appearing correctly

In the iOS app I am currently working on, the app hits a database to retrieve information every time the page changes. While waiting for the query to execute and the information from the query to populate the fields on the page there is supposed to…
Joseph Waelchli
  • 60
  • 1
  • 10
0
votes
2 answers

Thread with lot of autoreleased objectIs is it mandatory to use autorelease pool on this scenario if yes/no why?

Consider we are implementing our own thread with lot of autoreleased object. Is it mandatory to use autorelease pool on this scenario if yes/no why?
Ankit Vyas
  • 7,507
  • 13
  • 56
  • 89
0
votes
1 answer

Calling performSelectorOnMainThread with NSOperation

I have an issue where I have a NSOperation running in a background thread, and in the execution loop of that execution i call performSelectorOnMainThread to execute a NSURLRequest, But the main thread never gets the call to execute that…
stephen
  • 1,617
  • 3
  • 20
  • 27
0
votes
2 answers

iOS : Best way to organise multithreading

Guys I need some help to architect my multithreading in iOS. I'm using ARC in my code. So basically I need following, In my main thread nstimer fire some method which should be executed in a separate thread, that thread does some calculation and…
deimus
  • 9,565
  • 12
  • 63
  • 107
0
votes
1 answer

iOS : is there a leak?

.h: #import #import "Todo.h" @interface TodoCostApplyViewController : UIViewController { NSThread* headViewThread; NSThread* tableViewThread; } @property (nonatomic, retain) NSThread* headViewThread; @property (nonatomic,…
jxdwinter
  • 2,339
  • 6
  • 36
  • 56
0
votes
1 answer

NSOperationQueue waitUntillAllOperationsAreFinished blocks operations

I've created my own NSOperation subclass and now I want some of its instances to run in parallel. As it's a concurrent operation I've overwritten - (void)start { [self willChangeValueForKey:@"isExecuting"]; isExecuting = YES; [self…
Nickkk
  • 2,261
  • 1
  • 25
  • 34
0
votes
2 answers

NSTimer animation while main thread is drawing

I've read a million posts on stackoverflow about nstimers, runloops and the main thread but they don't seem to have the same problem or answer I'm looking for. My situation: I'm trying to animate some stuff while there is some 'loading going on'.…
Bob de Graaf
  • 2,630
  • 1
  • 25
  • 43
0
votes
1 answer

exit in NSThread

I'm writing a game. I have StartScene class: In StartScene.h: @interface StartScene : UIView { ... PlayScene* tView; NSThread* gameMechThread; } PlayScene is an inherited class @interface PlayScene : StartScene…
Alexander
  • 233
  • 1
  • 4
  • 14
0
votes
1 answer

NSThread Not Loading Selector Method

In the initialization method of a class I am declaring the thread as such: NSThread* myThread = [[[NSThread alloc] initWithTarget:self selector:@selector(m_run_thread) object:nil] autorelease]; [myThread start]; I also have a boolean value which…
Kevin
  • 1,469
  • 2
  • 19
  • 28
0
votes
2 answers

Multithread is slow?

i'm new ios and i don't know performance of NSThread an multithread on IOS. I've a function -(void) writeBlock:(NSString *)srcPath toPath:(NSString *)destPath fromIndex:(int)fIndex toIndex:(int)tIndex { //create file handle for srcPath and…
The Bird
  • 397
  • 2
  • 8
  • 19
0
votes
1 answer

Calling method in background to get Facebook notifications and Twitter mentions

I want to call a method in background to check for new notifications and mentions for Facebook and Twitter. How can I do this ? Currently I am calling methods on view will appear of main view only. If any notifications will be there then I have to…
DeviPhone26
  • 615
  • 2
  • 10
  • 16
0
votes
1 answer

Using only one NSThread for one method

I have refresh button in my app and method 'doRefresh' who run in background thread. Now if user press double click - method doRefresh run 2 times and more. I want if user press double click and more clicks, all previos threads stop work and…
Ilya Ilin
  • 2,283
  • 21
  • 27
0
votes
1 answer

Objective c - fetching core data objects in viewDidLoad

A lot of times I have a situation in my app where I'm pushing a view controller and fetching object from core data to fill the UI. Now I usually do this fetching in viewDidLoad on the main thread and I'm sure there is a better way to do this, maybe…
Eyal
  • 10,777
  • 18
  • 78
  • 130