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

How can i stop the background thread from the main thread in Iphone NSthread?

I start a background thread from my program while my main thread is checking something. If the checking goes false, I want to stop the running background thread and start it all over again with my new parameters. I want to stop it coz the thread…
wolverine
  • 2,967
  • 5
  • 31
  • 35
1
vote
2 answers

Iphone MultiThreading - How can I update the events in the interface(mainthread) from the background thread?

1.My mainView is a UIScrollView. I have to load 9 images as tiles onto it. 2.I am calling the function as a different thread to get the 9images and to load it into the interface(mainthread). By doing so, the interface remains responsive. 3.But the…
wolverine
  • 2,967
  • 5
  • 31
  • 35
1
vote
2 answers

Data between NSThread

I'll explain my problem. I need to maintain a tcp connection while my app is running, so I need to have regard to the connection on a background thread. I use the following to connect the socket and works well. on connection.m myThread = [[NSThread…
robertDraven
  • 99
  • 2
  • 8
1
vote
2 answers

Pause Main thread until background thread retrieves user input

In my main starting thread I need to pause the code and start a new thread and wait until I get user input. Then Id like to discard the new thread made and go back to where the main thread left off. But whats happening is that the new thread is…
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
1
vote
0 answers

Application crash when twitter login using FHSTwitterEngine

Now I Integrate the twitter functionality with FHSTwitterEngine Rest API V1.1. I was successfully Integrated and login functionality was worked great. But when I set the navigation to another controller based on success alert, the app was crashed…
raman
  • 175
  • 1
  • 2
  • 14
1
vote
1 answer

NSThread presentviewcontroller call?

How i can start an other viewcontroller in a thread? My code don't work: - (IBAction)btnGotoNextVC:(id)sender { [self.isLoading startAnimating]; [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; [NSThread…
1
vote
3 answers

Objective C: Autoreleased objects between threads?

If I have an autoreleased object and I need to provide it to a different thread, what is the best way to do so? Let's say I have an object that is autoreleased in thread 0. I tell thread 1 about this object and it retains it because it needs it.…
Friendly
  • 233
  • 1
  • 7
1
vote
3 answers

Using performSelectorInBackground to run loading indicator

I have such a code: [self performSelectorInBackground:@selector(indicator) withObject:nil]; [self mail]; //opening my controller of e-mail sending - (void)indicator { [actView startAnimating]; } This works fine, but i'm afraid of thread safety.…
max
  • 11
  • 2
1
vote
3 answers

How to make the main thread execution wait until a UIButton Action

I have a UITextField and save button when the user press save i want to popup an alert to confirm whether he want to save and wait for his response. But unfortunately it seems the alert view show doesnt stop execution or wait for user response. so…
Raon
  • 1,266
  • 3
  • 12
  • 25
1
vote
1 answer

problems with new thread

After trying many ways to call a function in new thread only the below code worked for me [NSThread detacNewThreadSelector:@selector(temp:) toTarget:self withObject:self]; The below didn't work: NSThread *updateThread1 = [[NSThread alloc]…
ebdo
  • 157
  • 3
  • 14
1
vote
2 answers

while loop can't exit without NSLog

I am trying to create a login page that displays a waiting page while attempting. it has an UIActivityIndicatorView runs on main thread and another thread doing the connection. The code works fine when I uncomment NSLog, but it keeps running when I…
JonatWang
  • 1,663
  • 1
  • 11
  • 11
1
vote
1 answer

Does calling executions on dispatch_queue_t ensure they are on the same thread?

If I store a dispatch_queue_t like so: @property(assign, nonatomic) dispatch_queue_t myQueue; ... _myQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); Later, when I do operations like dispatch_async(_myQueue, ^{ …
1
vote
1 answer

Memory issue with large NSData

I was reading a really large file into memory on the main thread (not just the simple dataWithContentsOfFile: method, I was also doing some data manipulation), and my app crashed. After I moved this process to a background thread, the app doesn't…
Levi
  • 7,313
  • 2
  • 32
  • 44
1
vote
2 answers

UIAlertView button results in a child NSThread

I would like a user to get a prompt screen, it would have yes and no options. The problem is the UIAlertView cannot be called from child thread, if I call it from child thread I am getting a runtime error(EXC_BAD_ACCESS). I am using NSThread on…
Sarp Kaya
  • 3,686
  • 21
  • 64
  • 103
1
vote
1 answer

Save in one managed context only of there are no changes in the other managed object context

I have two managed object contexts , say MMC and BMC pointing to same persistent store. Created by main thread(MT) and background thread(BT) respectively There are two fields delta and revision number in all my entities which is being changed by…
ila
  • 920
  • 12
  • 35