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

the relationship of autorelease and runloop and thread?

I have a question about the autorelease,now I have the code below: int main(int argc, char *argv[]){ @autoreleasepool { return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); }} the doc says at the end of the…
frank
  • 2,327
  • 1
  • 18
  • 20
2
votes
1 answer

CLLocationManager and serial location updates processing

I need to use the standard location service and perform some processing, including some network calls, every location update notified. I need location updates being processed in FIFO order, to keep tracking of the device, and get results as fast as…
2
votes
1 answer

Core Plot takes a long time to load

I have the following code in a method for setting up a CPTBarPlot: CPTGraphHostingView *chartView = [[CPTGraphHostingView alloc] initWithFrame:CGRectMake(10, 100, 290, 330)]; [self.view addSubview:chartView]; CPTGraph *graph = [[CPTXYGraph…
Tobias Frischholz
  • 331
  • 1
  • 3
  • 4
2
votes
1 answer

Cocos2d How to create progress bar(loading scene)

how in order load music, images, and other stuff to scene with progress bar and move bar smooth.. i guess logic of progress bar is to create new thread - load data and destroy thread here is my code to load stuff but it's not work, progress bar…
user1644430
  • 90
  • 2
  • 9
2
votes
2 answers

What's the difference between isMainThread and currentThread == mainThread?

I'm looking at some old code, and seeing the following if statement: if ([NSThread currentThread] != [NSThread mainThread]) I have a sneaking suspicion that this is not the same as if (![[NSThread currentThread] isMainThread]) I'm suspicious…
Mike
  • 1,112
  • 1
  • 13
  • 20
2
votes
2 answers

How Do I Properly Convert UIWebView with Chaning Content to UIImages

What I'm trying to do is to convert UIWebView to UIImage every time the content of webview was changed/loaded. Here is the code: - (void)viewDidLoad { [self.tmpWebView loadHTMLString:[NSString stringWithFormat:@"Some %i HTML",…
sag
  • 177
  • 1
  • 6
2
votes
2 answers

Understanding Multithreading in iOS

I am trying to understand multi-threading on iOS in more detail. I went through some of the class references like NSThread, NSRunLoop, NSTask.. First of all as indicated on the following link: use of runloop Runloop runs within a Thread. So why do…
shebelaw
  • 3,992
  • 6
  • 35
  • 48
2
votes
1 answer

Difference between calling a function in background and using calling a function in thread

I am not able to understand difference between calling a function in background like [self performSelectorInBackground:@selector(getFriendFaceBookList) withObject:nil]; and calling the same function in a Thread : [NSThread…
Vinod Singh
  • 1,374
  • 14
  • 25
2
votes
1 answer

How can UIActivityIndicatorView do not stop when the mainThread blocked?

How can UIActivityIndicatorView do not stop when the mainThread blocked?
bossbei
  • 99
  • 1
  • 4
2
votes
1 answer

CCMask and threads

I am using Gilles Lesire's CCMask class in my Kobold2d 2.0.3 (cocos2d-iphone v2.0 and OpenGL ES 2.0) game, but calling "createMaskForObject:withMask:" I get the following error: -[CCRenderTexture initWithWidth:height:pixelFormat:depthStencilFormat:]…
Rhuantavan
  • 445
  • 3
  • 17
2
votes
4 answers

NSTimer Not Firing in Subthread

I am trying to get a NSTimer to fire in a subthread. My code essentially looks like this: -(void) handleTimer:(NSTimer *)theTimer { NSLog(@"timer fired"); } -(void) startMyThread { // If I put timer in here, right before I start my…
rizzes
  • 1,532
  • 20
  • 33
2
votes
2 answers

NSThread setStackSize not setting the size of thread

I am using an NSThread and setting the stack size for it as follows: thread=[[NSThread alloc]initWithTarget:self selector:@selector(fibnocciForLoop) object:nil]; [thread setStackSize:12]; [thread start]; As written Apple docs for for -[NSThread…
Aniket K.
  • 144
  • 9
2
votes
1 answer

Run a background thread when application enter background

I need to schedule a task in background when the application enter background state. I have to do this in order to call a remote service each x time and then show a local notification when some event happend with the remote service. (I know it's…
Aladdin Gallas
  • 701
  • 2
  • 12
  • 36
2
votes
1 answer

Implement a block in background, then after completion run another block on main thread?

How do I implement the following block? I need to run some tasks in background. Then after the background task is completed, some tasks will be run in main thread. Why I use blocks is because i need to update a view that is passed into this…
AReality
  • 69
  • 1
  • 11
2
votes
1 answer

Keep NSTimer running when app is in background

I hope there's an expert out there who can help me with this: I googled it for hours, but could not find any information if there is any way to keep a running NSTimer active when the app is running in the background ? The problem scenario is I need…
Gaurav
  • 1,068
  • 9
  • 15