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

core data update in background

I need to basically update my core data in a background thread without blocking UI and save it. After saving should reload table View to view the changes. So for doing this I thought of using dispatch_async(…
aparna
  • 353
  • 2
  • 3
  • 13
0
votes
1 answer

The blue focus ring outside NSTextField missing?

In normal case, a blue retangle would appear outside a NSTextField object which becomes the first responder, like this image: link for Normal Case However, I got a NSTextField that have no the blue border outside. Why is that? Here is how it…
Andrew Chang
  • 1,289
  • 1
  • 18
  • 38
0
votes
1 answer

Start thread when iOS application enters background state

I have a Requirement where I need to Create and Start a thread when application enters the Background State. The function of the Created Thread is to fetch data from local DB and upload to server, and I don't need to do any updates on UI. My…
RockandRoll
  • 409
  • 5
  • 23
0
votes
2 answers

Display UI, from a background thread without breaking the flow

I have a code executing in the background thread, which is performing some kind of computation and is within a do-while loop. Due to some changes in the requirements, I have to display a UI to prompt user for input. This UI code will have to be…
Anna
  • 945
  • 1
  • 9
  • 13
0
votes
1 answer

Adding subViews on non-main Thread not displaying

I create a UIView contentView and display it. I then fetch data from server and create a bunch of subviews displaying the data. I am using MBProgressHUD to display while waiting on data. if (datasetSubBar.panels == nil) { MBProgressHUD *HUD =…
Padin215
  • 7,444
  • 13
  • 65
  • 103
0
votes
2 answers

How to send alive packet when application in background - IOS?

I am working on an voip application, I need to maintain connection with the server always even when application goes background, apple is provding support to use communication socket, my problem is I have a separate server (i.e consider login…
Newbee
  • 3,231
  • 7
  • 42
  • 74
0
votes
1 answer

Alternative methods to receive return value from a (former) function running in separate NSThread?

I've started refactoring my code recently and I'm trying to increase performance by using more threads. Especially for downloads and connections. I've had a function called... - (UIImage *)imageFromURLString:(NSString *)urlString; ...which just…
Git.Coach
  • 3,032
  • 2
  • 37
  • 54
0
votes
1 answer

NSOperationQueue Calling performSelectorOnMainThread crashes the application

I'm using the following code to download some pic from the server, -(void)viewDidLoad { for (int i = 0 ; i < picsNames.count ; i++) { UIImageView *imageView = [[UIImageView alloc] initWithFrame: CGRectMake(i * 320.0, 0.0, 320.0,…
Mona
  • 5,939
  • 3
  • 28
  • 33
0
votes
1 answer

Any special autorelease actions for a variable passed from one thread to another(iphone)

I have a NSDictionary that is passed from the main thread to a second thread which retains, uses, then releases the variable. What if the main thread autorelease pool is drained while the 2nd thread is still using the variable? Even though I have…
Brenden
  • 7,708
  • 11
  • 61
  • 75
0
votes
1 answer

NSThread Memory Leak

I'm using an NSThread as follows NSThread * thread = [[NSThread alloc] initWithTarget:object selector:@selector(bg) object:nil]; [thread start]; Later on I want to stop the thread and deallocate object as follows: [thread cancel]; [object…
George
  • 1,457
  • 11
  • 26
0
votes
1 answer

Allocated object cannot be released in loop on seperate thread

I have an NSThread that runs the following code: for (Experiment *exp in experiments) { ExperimentBlock *block = [[ExperimentBlock alloc] initWithFrame:CGRectMake(0, maxHeight, 310, 50) …
0
votes
1 answer

Does NSThread have a separate heap? What about pthread (on iPhone)

If I detach an NSThread will Cocoa run it in a separate memory heap or memory zone? For example, if I were to detach a thread, use malloc to create a large buffer, and then let the thread exit, would I get that memory back in some kind of automatic…
Simon Woodside
  • 7,175
  • 5
  • 50
  • 66
0
votes
1 answer

Will detached NSThreads always complete prior to application exit?

When using NSThread's detachNewThreadSelector:toTarget:withObject:, I'm finding that the thread will fully complete its execution before the application is terminated normally if the user were to attempt to quit the application while the background…
mliberatore
  • 341
  • 1
  • 10
0
votes
2 answers

Create autorelease pool on posix thread

I'm using a GTMLogger functions for formatted logging in my application. This application creates real-time posix threads (audio packets processing). Sometimes we need to perform a logging from within these non-Cocoa threads. GTMLogger creates…
Nava Carmon
  • 4,523
  • 3
  • 40
  • 74
0
votes
1 answer

What I should use for parallelisation of frequent HTTP requests to the REST server in iOS application: GCD or NSThread?

I'm developing an application which must extract new messages for user from the server. I have implemented this as a timer which fires every 2 seconds and call a selector which is a method that implement HTTP request and server respond processing.…