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

Objective c: Getting error when adding object into NSMutableArray during threading

Here is what I want to achieve. 1. Searching all the files 2. find all .jpg files during the searching 3. save all .jpg file paths into NSMutableArray Here are the codes: Created the NSMutableArray: NSMutableArray *jpgFiles = [[[NSMutableArray…
YU FENG
  • 888
  • 1
  • 12
  • 29
0
votes
2 answers

How to handle concurrency by queue/NSThread for UI design, iOS dev

What I am trying to achieve is simple, from first thinking though. I found it hard to handle at last. I would like to push a table view as a selection list, user select one cell and the cell string was sent to the previous view as selected string,…
JimZ
  • 1,182
  • 1
  • 13
  • 30
0
votes
3 answers

Is there a way to make an NSthread run even when the app is in background?

I have an NSThread that checks for new data on the internet. Is it possible to run this thread even when the app is in background by the user in order to check if new data arrived and then show a local notification? Any help appreciated. Thanks!
stefanosn
  • 3,264
  • 10
  • 53
  • 79
0
votes
1 answer

Core dump in multithreaded program: basic_string::_S_construct null not valid

I want that 4 threads will come into the same function named read and do what there is in the function (to read, after it to print on the monitor, and to show it all...). The problem: terminate called after throwing an instance of…
Vladi
  • 1,662
  • 19
  • 30
0
votes
3 answers

Load Large Data from multiple tables in parallel using multithreading

I'm trying load data about 10K records from 6 different tables from my Ultralite DB. I have created different functions for 6 different tables. I have tried to load these in parallel using NSInvokeOperations, NSOperations, GCD, Subclassing…
0
votes
1 answer

iOS exec function in background

I am new to multithreading and was wondering how I could run this function in the background? The function simply returns a NSURL that is used for XML parsing and is called from another function. Or is it even worth it to run in the background since…
Jon Erickson
  • 1,876
  • 4
  • 30
  • 73
0
votes
2 answers

Calling a function through thread giving an exception

I am using the thread to call my function "initialGetMethod" [NSThread detachNewThreadSelector:@selector(initialGetMethod) toTarget:self withObject:nil]; and my get method is -(void) initialGetMethod { self.loginPassword = [[ UIAlertView…
Raju
  • 39
  • 6
0
votes
2 answers

Long lived thread doesn't call performSelectorOnMainThread

I have a worker thread that I keep alive through a loop that's controlled by a flag. I need the thread to stay alive for the length of my application as it opens a permanent connection to a remote server. I fire up that thread and call several…
ruipacheco
  • 15,025
  • 19
  • 82
  • 138
0
votes
1 answer

App modal NSPanel / sheet / dialog + NSThread == window hangs?

I'm in the midst of debugging an extremely unusual problem, and I was wondering if anybody might have any insight into what might be going wrong: In a controller class from a NIB, I take an NSPanel from that same NIB, and then show it app modally on…
MarcWan
  • 2,943
  • 3
  • 28
  • 41
0
votes
1 answer

NSThread is failing to load Selector method

So, I am trying to connect to a remote server to get and show data. in viewDidLoad I use an NSThread to call a function called doSomething - (void)doSomething { @autoreleasepool { NSMutableURLRequest…
Eyad Fallatah
  • 1,859
  • 4
  • 22
  • 34
0
votes
2 answers

Using NSUrlConnection inside either NSThread or NSOperation

I am developing a static library that needs to do some stuff in the background, without interacting with the main thread. To give you an idea, think of just logging some user events. The library must keep doing this stuff until the user exits the…
Marc
  • 3,386
  • 8
  • 44
  • 68
0
votes
1 answer

Problems with NSNotificationCenter and loading the UIViewControlletr

I have a UIViewController with button that brings another UIViewController. with clicking on button , as shown in my NSLog, and when this is done, I want to send a notification to load another viewcontroller . Well, although it seems everything is…
user1997934
0
votes
1 answer

Obj-C: Checking if a window exists in a thread

He, I programmatically create a window in a thread when a button in my main window is clicked. If this button is clicked again, the window closes. Fine. But when the user closes the window via its close button, the thread isn't aware of that,…
fw2601
  • 83
  • 6
0
votes
1 answer

Displaying a waiting dialog or indicator while saving a photo in iOS, is it worth it?

I don't know if it's correct or not to show a waiting dialog/indicator while saving a photo taken with the camera. In iPad 4 the saving process is very fast, but maybe on other devices this process could take more time. Start a new thread to save…
Xithias
  • 991
  • 1
  • 14
  • 32
0
votes
1 answer

core data in background

UPDATED Version of core data update in background. with the help of link Grand Central Dispatch (GCD) with CoreData created a background managedObjectContext but I am getting an error when fetching from core data -(void) startTimerThread { …
aparna
  • 353
  • 2
  • 3
  • 13