nsthread

Problem with NSThread

I have a question; in my program if i call 2 times [self performSelectorOnMainThread:@selector(callDectectionMove:) withObject:[NSNumber numberWithInt:(int)i] waitUntilDone:false]; I create 2 thread or not? Because in my program i'm not sure to create 2 threads. Thanks -(void)callDectectionMove:(NSNumber*)arrayIndex{ NSMutableDictio...

Problem with NSThread

Hi, I have a problem with my code I wanna create 2 different instance with NSThread but i think in my problem these doesn't happen. Can you take my a solution for my problem. I post my code, if you can you may show a solution example? Thanks @implementation myClass -(void)detectMove:(NSNumber*)arrayIndex{ NSMutableDictionary *...

NSAutoreleasePool issues on the iPhone

Hi all, I have a small iPhone app which has a button on the first view. When I select this button I load up my new view which has an image on it. I'm currently using the following code to load the image from an online source on a separate thread, whilst allowing the user to continue controlling the application: - (void) loadImageTest {...

Reachability problem with notifications on a separate thread

Hello, I make use of Apples Reachability class and it works if I keep it on the main thread(bad approach). If I instead move it to a separate thread the notification is never called. In didFinishLaunchingWithOptions i call the following: [NSThread detachNewThreadSelector:@selector(checkConnection) toTarget:self withObject: nil]; che...

iPhone UIBarButtonItem setEnabled in NSThread

Hello, I'm trying to change the enabled property of an UIBarButtonItem after doing some stuff in an NSThread. After pressing the button I set the enabled to NO then perform the threaded part and at the end I try to re enable the button. Fairly basic. Somehow this fails, however I'm able to change any other property of the the UIBarButt...

How to update a UILabel frequently?

Hey guys, I am currently working on a project where I request and parse multiple html sites in a controller. To give some feedback to the user I have created a second view, which gets displayed during processing of the data. It displays a status label and a progressbar. In my controller I have several points where I update my labels tex...

Cocoa and getting out of infinite loops

Hi, The basic idea I have is to click on one button and enter an infinite loop. I plan to click on another button to stop and get out of this loop. Trouble is once I get into the infinite loop, my second click is never detected so I can't get out. Any idea's on how I can get this to work ? Thanks a ton. -(IBAction) startButton { while...

Deleting Managed Objects in Background Block

On iPhone, I´ve tried to delete managed objects in background: - (void) cleanUp { dispatch_queue_t queue_cleanUp; queue_cleanUp = dispatch_queue_create("com.aroundcal.cleanup", NULL); dispatch_async(queue_cleanUp, ^{ while (!self.stopThread) { [self deleteMyObjects]; [NSThread sleepFor...

NSThread problem on iPhone

I'm using two threads in an iPhone app for the first time and I've run into a problem. In this prototype, I have a view controller that loads a local web page. I want an activity indicator to show until the page has finished loading. With the code below, the activity indicator starts, the page loads properly, but the activity indicator d...

Is it safe to to self destruct an NSThread?

Hey all, I have a pretty standard setup. I have a UIViewController to handle user interaction and a somewhat long running NSThread that does the actual work when the UI Controller shows up. One issue I've had is when I want to cancel the NSThread. Standard NSThread semantics is alright. I want the thread to finish, clean itself up (so t...

Finding all active threads

I need to find a way to enumerate all my iPhone application's active threads. This is strictly for debug purposes. Private APIs, if any, are welcome as well. I know I can see all the current threads in the debugger window, but I would like to have access to the actual NSThread objects, if that is at all possible. ...

NSRunLoop is receiving a strange selector; possible race condition tomfoolery?

I've got some threads doing heavy work while my main thread handles the UI stuff. The threads callback to the main thread at times to update a progress bar. All in all, it's not that stable. I've fixed problems relating to the logic, but one in particular persists. I've got some code that acts like a stop button, meaning that the thread...

Does NSLog'ing something alter its retain count? Because I am slowly going insane here.

Further to this question: http://stackoverflow.com/questions/3576724/nsrunloop-is-receiving-a-strange-selector-possible-race-condition-tomfoolery - where it was discovered that a UIGestureRecognizer was being deallocated and then receiving a message, I printed out the address of one of my GRs in order to see if it was the one being repor...

NSInvocation Leaks

I am trying to setup an NSInovcation system to launch selectors into background threads using performSelectorInBackground: - So far everything is successful when running the system on instance methods (-), but I also want to support class methods (+). I have adjusted my code to provide an invokeInBackgroundThread for both types of class ...

Call a delegate's method within a background

Hi, this is my first question here, so excuse me if I made any mistakes! In my iPhone project I have a method running in a thread which takes a long time to execute (that's why it runs in a thread). [NSThread detachNewThreadSelector:@selector(methodToBeCalledInAThread) toTarget:self withObject:nil]; // ... -(void)methodToBeCalledInAT...

Load an OpenGl view in the background. iPhone

I have an OpenGL view that renders a 3D model. It is a basic modification on Apples EAGLView. This view is added to a controller's .view and displayed with presentModalViewController: . I would like to do all of the model loading, and OpenGL state configuration in a background thread at app launch before the user chooses to display the v...

Deadlocks: How do you determine if a call may cause unsafe painting off of the main thread for iOS?

Drawing/painting should always be done on the GUI thread otherwise deadlocks can occur!... How do you determine if a call may cause unsafe painting off of the main thread for iOS? The problem is we get stacks like this which are not on the main thread... #19 0x02a788d2 in -[CALayer drawInContext:] #20 0x02a784b0 in backing_callback #2...

NSThreading for speed

I'm working on a game sim and want to speed up the match simulation bit. On a given date there may be 50+ matches that need simulating. Currently I loop through each and tell them to simulate themselves, but this can take forever. I was hoping 1) Overlay a 'busy' screen 2) Launch a thread for each 3) When the last thread exits, rem...

iPhone upload in new thread

Hi All, I've been trying to implement a background thread in my app to do the long haul, hard graft uploading stuff. I'm using the FBConnect SDK and it has been working perfectly but I would like to keep the GUI side working smoothly and at the moment there is a noticeable pause in the app before it starts the upload. What happens at ...

NSRunLoops in Cocoa?

Hi guys, Let's say I have 2 threads, one is the main thread and another one, a secondary thread. The main thread is being used the most, but sometimes (rarely) I want the secondary thread to do some work based on calls from the main thread. Most of the time the secondary thread should sleep. Now after some searching I understand the wa...