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

iOS: Autoreleased objects across NSTheads

I gather that if I create an autoreleased object and I pass it to another thread to be worked on, this is bad if the first NSThread should happened to clean out its autorelease pool, or be killed. However if I want to avoid autoreleasing as a rule,…
0
votes
3 answers

Stop NSThread while downloading

I have an iPhone app, where I'm displaying a tableview, that's loaded from an RSS feed. When the view is loaded, I call this method to run in a new NSThread: - (void)start:(NSURL*)url { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]…
Xunil
  • 295
  • 2
  • 4
  • 11
0
votes
2 answers

Detect when block is added to Grand Central Dispatch?

I have an iOS application using NSThreads for concurrency tasks. I will try to migrate it to be using the Grand Central Dispatch (GCD) for handling concurrency. The problem is that the app needs information regarding how many threads has been…
0
votes
1 answer

Effective way to use NSThread and autorealease pools in iOS

I'm using the MBProgressHUD library in my app, but there are times that the progress hud doesn't even show when i query extensive amount of data, or show right after the processing of data is finished (by that time i don't need the hud to be…
0
votes
0 answers

MBProgressHUD crashing the app while doing work in another thread

I am trying to do some work in thread for which I am using the MBProgressHUD. When I try to do the following code, it is crashing. if ([database databaseNeedsMigration]) { HUD = [[MBProgressHUD alloc] initWithView:self.view]; HUD.labelText =…
Saty
  • 2,563
  • 3
  • 37
  • 88
0
votes
1 answer

A function giving synchronous calls to a stored procedure on remote server causes memory warnings

I am uploading Zips containing folders of images from my application on a remote server in my iOS app. The function is called in a separate NSThread so it should not block the UI. Here I create batches of folders containing images (of max 10 MB) and…
Yogi
  • 3,578
  • 3
  • 35
  • 56
0
votes
2 answers

How can I change the background operation priority dynamically using Dispatch or Operation queues.

Here is the problem that I got. I have several tasks to complete in background when application is running. When I run these tasks in background by pushing them to concurrent dispatch queue it takes more then 10 seconds to complete all of them. They…
0
votes
1 answer

NSThread object retained twice?

I have a class derived from NSThread: @interface FSEventMonitorThread : NSThread { FSEventStreamRef m_fseStreamRef; CFRunLoopRef m_runLoop; } - (id) initWithStream: (FSEventStreamRef)fseStreamRef; - (void) dealloc; - (void)…
Paul J. Lucas
  • 6,895
  • 6
  • 44
  • 88
0
votes
1 answer

Delegation in a NSThreaded Design? (iPhone)

Im using a large amount of very small web services in my app and I have been down a couple of roads that does not scale or work as desired. The Design approach Im thinking about: The task for the viewController is to ask for a set of data from a…
RickiG
  • 11,380
  • 13
  • 81
  • 120
0
votes
1 answer

NSThread Causing memory Leaks in iPhone

I am uploading images chunk wise, in a background thread, each chunk will be size of 512kb,to the best of my knowledge,i have taken care of memory leaks using release,nsautoreleasepool. Below is the code for uploading images chunkwise. -…
RockandRoll
  • 409
  • 5
  • 23
0
votes
2 answers

Using NSThread to create game loop

I'm trying to create game loop which runs in separate thread. I decided to use NSThread object instead of CADisplayLink and NSTimer. To test if OpenGLES is working correctly I'm clearing the screen by solid color. The problem here is that all is…
user1687498
  • 61
  • 1
  • 7
0
votes
0 answers

iOS - App needs establishing a session and keep feeding watch dog to keep this session on, which kind technology will be involved?

Condition: The App will talk with a Device with IP host. The device has its own communication protocol above IP layer (Transport layer) in Session layer. To start talking, the App needs establish a Session by several times handshake on session…
Yi Jiang
  • 3,938
  • 6
  • 30
  • 62
0
votes
2 answers

How can I detach a thread without calling the selector, or at least make a work-around?

So I have a view controller with a timer. It has one button. When the view loads for the very first time, the button should say "start." When it is tapped, "start"->"pause". Another tap, "pause"->"resume". Another tap, "resume"->"pause". Since I…
EvilAegis
  • 733
  • 1
  • 9
  • 18
0
votes
1 answer

Returning NSArray of UIImages from ALAssetsLibrary

I'm working on photo app and here is the deal: I have created custom photo album an added some photos to it (users can create many albums). I used ALAssetsLibrary for this and CustomPhotoAlbum category. Everything worked flawlessly until I needed to…
cojoj
  • 6,405
  • 4
  • 30
  • 52
0
votes
1 answer

usleep() locks the iPhone prompting

I am using CLLocationManager, if the program is installed for the first time, it requires user to accept or deny to share his location. What I want is to program itself to wait until user prompts. Now the issue is I am waiting there with…
Sarp Kaya
  • 3,686
  • 21
  • 64
  • 103