nsthread

Can i call a NSThread function detachNewThreadSelector: toTarget: withObject: with 2 parameters?

I want call a function which makes my main thread stuck using the above function so that it can run in a diff thread. But the problem is that my function have 2 parameters. Is it possible to do so? ...

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 problem even when the images are being loaded they doesnt get displayed in the UIScrollV...

How to force screen update for UIScrollView from non-UI thread/function (iPhone)

I am drawing a set of images on the uiscrollview from a non-ui thread/function. But its only displayed after all the images are done drawing. For drawing all the images, I have written a function and that is what is being called as the non-ui thread. I did write this line inside the function [self performSelectorOnMainThread:@selector(u...

pthread vs NSThread: which is faster

In Cocoa, is NSThread faster than pthread? is are any performance gain? is it negligible to ignore? ...

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 will be downloading images and if I doesnt stop it and call it again, it will take a lot of ...

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 class is singleton, so if i start new timer the old timer get dealloc it . + (void)timerThrea...

NSTimer within NSThread Memory grows ?

I am using a timer within a thread , i am instantiating the timer all the time however when i run the application within instrument i see the memory grows exponentially, i am not having any leaks. I am sure that NSThread is causing the growth ? . I am stopping the current timer before running a new one (singleton) and i am releasing eve...

iPhone app freezes when parsing XML

My app freezes whenever I parse an XML feed. I have tried calling this instead: [NSThread detachNewThreadSelector:@selector(parseXML) toTarget:self withObject:nil]; which calls: -(void) parseXML { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [self parseXMLFileAtURL:path]; [pool drain]; } but my app has ...

Running NSTimer on a thread

I am trying to run a NSTimer on a thread using iPhone SDK 3.0. I think I am doing everything correctly (new runloop etc.). If I call [timer invalidate] on viewDidDissappear though I get this error: bool _WebTryThreadLock(bool), 0x3986d60: Tried to obtain the web lock from a thread other than the main thread or the web thread. This ma...

iPhone: Best Practice for Using NSThread to Load Thousands of Images?

Hi, I am trying to load thousands of images using NSThread but the performance is quite slow. What would be the best practice to use NSThread to download thousands of images? Thanks, Jim. ...

When to release/retain an object that is passed to a secondary Thread?

Hello, I am passing an object to a secondary thread using the following code: (void)login:(id)sender { platformMsgs_LoginRequest *loginRequest = [[[platformMsgs_LoginRequest alloc] init] autorelease]; //more code... [NSThread detachNewThreadSelector:@selector(sendLoginRequest:) toTarget:self withObject:loginRequest]; //more code......

When NSThread returns to a released object? (iPhone)

Hi 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 an NSThread. This is done every 3 minutes and this delay is controlled by a: [self ...

NSThread, AsyncSocket and object deallocation

Hi! I have a piece of network code that uses AsyncSocket but moves it to a separate runloop. I'm creating this runloop with the following piece of code: [NSThread detachNewThreadSelector:@selector(_workerLoop) toTarget:self withObject:nil]; and here's how my _workerLoop looks like (they're both in the same class): -(void)_workerLoop...

NSURLConnection performance

Hi all, I'm using NSURLConnection for downloading some images in my app currently. Before implementing via this, I implemented it by NSData(dataWithContentOfURL) in NSThread. But I wanted to cancel during downloading images, So I changed it to NSURLConnection. But It happens other problem. Performance was very low after changing. For ...

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

Hi 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 dealloc and synchronize all the different parts so that I avoided memory bug. Instead ...

Run code for a certain length of time and kill if necessary

I'm using the scripting bridge to query iTunes from my cocoa application. Sometimes iTunes pops up a window (like if an ipod needs updating etc.) and while that popup window is open I can't get any information from iTunes. So if I request information from iTunes when it's in this state my application completely locks-up until that popup ...

calling selector with two arguments on NSThread issue

I'd like to make a Thread with multiple arguments. Is it possible? I have the function: -(void) loginWithUser:(NSString *) user password:(NSString *) password { } And I want to call this function as a selector: [NSThread detachNewThreadSelector:@selector(loginWithUser:user:password:) toTarget:self withObject:@"someusername" withOb...

What happens to a thread's memory when it is cancelled?

I'm writing code to check if there is a network connection present. In a nutshell, the order of events that I want to occur goes like this: User requests information from a web service. A timer starts, and checks every second if a connection exists. If it doesn't, put up a view. When the information is all received from the web servi...

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 dictionary). At this point I get undefined results. Using NSLog (I'm not advanced in XCode debug...

iPhone Simplest Communication between Threads

I have an iPhone app with a secondary thread to handle XML parsing. Inside some of those methods, I need to reference dictionaries (for look up, not modification) created and populated in the main thread. Apple's documentation indicated to me that global variables might be the best way to accomplish this. I'm just now sure what the impl...