nsthread

iPhone: One Object, One Thread

On the iPhone, I would like to do some operations on an image in a separate thread. Rather than dealing with semiphores, locking, etc., I'd like to use the 'One Object, One Thread' method of safely writing this concurrent operation. I'm not sure what is the correct way to copy my object into a new thread so that the object is not acces...

How can i get a list of currently running threads in objective-C(iphone)

Is there a way to get the list of currently running threads in objective-C? I'm mostly interested in getting the NSThreads objects, cause i want to replace the assertion handler for each running thread? If such thing is not possible, maybe i could set my own selector to be invoked after any thread is spawn(so that i could do the asserti...

xmlCtxtGetLastError - Iphone

Hi, I have been programming with NSXMLParser for quite a while and lately, I came out with this error. The strangiest thing is that it only happens in debug mode. Once I load the App in Simulator and run it from Simulator (without Xcode involved), it runs fine. The code is very straight foward, it is a simple XML parsing whose contents...

Timeout a NSThread after a certain amount of time

Hello, I have a NSThread that i would like to timeout after a certain amount of time. [NSThread detachNewThreadSelector:@selector(someFuntion) toTarget:self withObject:nil]; - (void) someFunction { //Some calculation that might take a long time. //if it takes more then 10 seconds i want it to end and display a error message } ...

Strategy for animating a lot of "LED's" - thread?, UIView animations? NSOperation? (iPhone)

Hi I have to do some different views containing 72 LED lights. I built an LED Class so I can loop through the LED's and set them to different colors (Green, Red, Orange, Blue None etc.). The LED then loads the appropriate .png. This works fine, I loop over the LED's and set them. Now I know that at some time they will need to not just...

NSThread shared object issue

Hi, I'm getting an “EXC_BAD_ACCESS” but just can't work out why, any help would be massive - thank you in advance. The user takes a picture and I want to do some processing on it in another thread... - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { ... NSString *uid...

NSThread with class method?

Is it possible to run a class method (starting with a '+') in a separate thread? Normally I call the method like [myClass myController]; I tried [NSThread detachNewThreadSelector:myController toTarget:myClass withObject:nil]; without success. ...

When we should use NSThreads in a cocoa Touch ?

I am writing a small game by using cocos2d. It is a shooting game. Player on one side and enemy on other side. To run the both actions of player shooting and enemy shooting do we should use threads ? Or can we do without using them. At present I am not using threads. But I can manage to do both actions of player and enemy at same time. S...

MKMapView Not Loading When Called on an NSThread?

I am creating a MKMapView in a method named "generateMap". From inside viewDidLoad, this works: [self generateMap]; but this causes the map to quickly load and then disappear, leaving only the blank grey grid: [NSThread detachNewThreadSelector:@selector(generateMap) toTarget:self withObject:nil]; Any ideas why this might be happeni...

How to execute an NSUrlConnection in a separated thread?

Hello everybody, I am moving my first steps both with url connections and threads so bear with me if the question may result trivial. Basically I would like to execute an NSUrlConnection in a separate thread (even if this may result 'dangerous' as many documents state). Before deciding whether to adopt this solution or not I should manag...

Memory allocation in detached NSThread to load an NSDictionary in background?

I am trying to launch a background thread to retrieve XML data from a web service. I developed it synchronously - without threads, so I know that part works. Now I am ready to have a non-blocking service by spawning a thread to wait for the response and parse. I created an NSAutoreleasePool inside the thread and release it at the end ...

Difference between NSThread and detachNewThreadSelector:toTarget:withObject:

In the NSThread documentation, I came across the method detachNewThreadSelector:toTarget:withObject:. What's the difference between that method and creating a thread with initWithTarget:selector:object: and then starting it with start? ...

NSThread and memory management

Imagine I create and execute an NSThread object using detachNewThreadSelector:toTarget:withObject:. The method executed by the thread might look like this: - (void)search { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // perform a lengthy search here. [pool release]; } I then might use the cancel method to...

Keep a reference to an NSThread around and message its objects?

Hi I am a bit uncertain on how to do this: I start a "worker-thread" that runs for the duration of my apps "life". [NSThread detachNewThreadSelector:@selector(updateModel) toTarget:self withObject:nil]; then - (void) updateModel { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; BackgroundUpdate *update = [[Back...

invoking PopViewController on Main Thread from Secondary Thread

Hi Friends, I am doing my functionality in a secondary thread and once I get the result, I call the function that pops my ViewController in the main thread. But I get the following error: void WebThreadLockFromAnyThread(), 0x5c6dec0: Obtaining the web lock from a thread other than the main thread or the web thread. UIKit should not be ...

NSTask or NSThread?

I have some code that is attached to an NSTimer. Around 5 times every second, it interacts with another application (by emulating keystrokes) and when appropriate spits out an NSNotification, that is handled by another piece of code. While the timer code is running, the UI is unresponsive, so I can't include a 'stop' button that halts ...

Calling UIGetScreenImage() on manually-spawned thread prints "_NSAutoreleaseNoPool():" message to log

This is the body of the selector that is specified in NSThread +detachNewThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; while (doIt) { if (doItForSure) { NSLog(@"checking"); doItForSure = NO; ...

nsthread in iphone xcode

Good Day! i want to use nsthreads in a project of xcode that will call a function which is for the network access and will check that if the network is there or not, so i need to have a thread which will execute after lets say 1 minutes to check the connectivity. and will continue run unless the app is closed. [NSThread detachNewThread...

Using NSThread to solve waiting for image from URL on the iPhone

So I have the following code in a method which I want to set a UIImageView image to that of one from an online source: [NSThread detachNewThreadSelector:@selector(loadImage) toTarget:self withObject:nil]; Then in the method called by the thread I have this: - (void) loadImage { NSURL *url = [NSURL URLWithString:logoPath]; // logo...

Pass an Object of to an NSThread and keep sending it messages?

Hi All examples/tutorials I can find regarding NSThreads and the only way I have ever dealt with them is using [NSThread detachNewThreadSelector:@selector(processDataMethod) toTarget:self withObject:nil]; to move all processing in a method to another thread sporting its own autoreleasePool etc. This is good for "one shoot" operations t...