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
1 answer

why NSThread can clear autoreleased objects without creating my own autoreleasepoool

all. i have test codes as below: - (void)viewDidLoad { [super viewDidLoad]; [NSThread detachNewThreadSelector:@selector(test) toTarget:self withObject:nil]; } -(void)test { MyClass *obj = [[[MyClass alloc] init] autorelease]; …
eliudnis
  • 239
  • 3
  • 6
1
vote
1 answer

understanding sync and asyn operations

I am learning how to make sync and asyn operations . Please correct me what i have mentioned/learned are right: sync and asyn operations can be done in following ways(we can pick any according to our…
dinesh
  • 72
  • 1
  • 7
1
vote
2 answers

Accessing Instance Attributes from Secondary Thread (iPhone-SDK)

I have a class with an NSDictionary attribute. Inside this class I dispatch another thread to handle NSXMLParser handling. Inside my -didStartElement, I access the dictionary in the class (to compare an element found in the XML to one in the…
Ternary
  • 2,401
  • 3
  • 31
  • 54
1
vote
2 answers

Detect if method is called in background / foreground

I would like to detect if a method in objective c is called and executing on NSThread that is running on foreground or background. Thanks
1
vote
1 answer

Dismissing the keyboard while simulating a wait

This function is designed to simulate a wait if the user is successful logging in. As you can see I dismiss the keyboard first but that doesn't stop NSThread from sleeping before the keyboard is dismissed. I think I need to harness the power of the…
Macness
  • 1,226
  • 2
  • 13
  • 24
1
vote
1 answer

Creating a animated loading frame w/ condition NOT animated launch screen

Hi a few view controllers in my app do some pretty intensive image processing at load up. So what Id like to do is create a full screen animated image(which I already know how to do with image view) and continue animating until the view controller…
user3550397
1
vote
2 answers

Keep an NSThread containing an NSTimer around indefinitely? (iPhone)

I have some web service data in my app that needs to be updated every 3 minutes. I had tried out a few approaches but got a really good piece of advise in here last week, I should not build a new thread every 3 minutes and then subsequently try and…
RickiG
  • 11,380
  • 13
  • 81
  • 120
1
vote
1 answer

How to render OpenGL ES objects outside of main loop?

In an application I'm creating with GLKit, I have a slider puzzle where the user taps on tiles adjacent to an empty tile and the tile slides to the new position. To reduce the number of methods I had to perform a single task, I decided to try…
michaelsnowden
  • 6,031
  • 2
  • 38
  • 83
1
vote
2 answers

Dissmiss uiview using PerformeSelectorOnMainThread

have a publish option in my app, where the user fills the information and it's send to my webservice. I have the "form" on a modal view. And a function that I use to close it, when the button Cancel is touched. When the publish button is touched, I…
Kio Coan
  • 561
  • 2
  • 7
  • 24
1
vote
1 answer

When NSThread returns to a released object? (iPhone)

I have got a memory bug that seems to boil down to something happening in a thread. I am having difficulties troubleshooting this. I have a UIViewController, that when active, i.e. the user is using its view, retrieves updates from a web service in…
RickiG
  • 11,380
  • 13
  • 81
  • 120
1
vote
7 answers

Tableview scrolling crashes app

I am developing iPhone app in which i am downloading image from server in background, Here is view of my application, when i click on Button 1 i am fetching 5 data from server also images, after fetching data when user scrolls up i am fetching new…
Krunal
  • 6,440
  • 21
  • 91
  • 155
1
vote
3 answers

How to start and stop background thread iOS

I am developing an iPhone app in which, I want start background thread for downloading image from server. while downloading the image if user wants to cancel a download then on click of button he can cancel downloading means I want to stop execution…
Krunal
  • 6,440
  • 21
  • 91
  • 155
1
vote
2 answers

In main I spawn a new NSThread, and at a later point in main when a condition is met I want to stop the thread. How?

In my main function for my command line program, I create a new instance of an NSThread subclass, and call start on it, where it runs a timer in a different thread. If the user wants to stop the timer, they type "stop" and I want it to end the…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
1
vote
1 answer

Runloop and autoreleasePool

In Apple API Reference about NSAutoReleasePool https://developer.apple.com/library/ios/documentation/cocoa/reference/foundation/Classes/NSAutoreleasePool_Class/Reference/Reference.html It point that "The Application Kit creates an autorelease pool…
1
vote
2 answers

Running NSTimer Within an NSThread?

I am trying to run a timer in the background of my application, i am using the timer heavily in my application and i'd rather running it in the background, However i am getting memory leaks when trying to release the NSAoutreleasePool. My Timer…
Unis
  • 365
  • 1
  • 4
  • 13