views:

33

answers:

1

For some reason calling an NSPathControl object in a thread is causing crashes.

- (IBAction) action5:(id)sender {
 [outlet_NSPathControl1 setURL: [NSURL fileURLWithPath: @"/Users/admin/"]]; // Works fine here
 [self performSelectorInBackground:@selector(background1) withObject:self]; // Jump to the thread
}

-(void) background1 {
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 [outlet_NSButton1 setTitle: [NSString stringWithFormat: @"%d", index]];
 [outlet_NSPathControl1 setURL:[NSURL fileURLWithPath: @"/Users/admin/"]]; // Crashes here
 [pool drain];
}
A: 

"Crash" isn't really descriptive enough to offer any specific help, but if a class isn't listed as being thread safe, then it probably isn't.

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html

UI elements should also generally only be updated from the main thread.

Azeem.Butt
Thank you for the information. I'm new to Mac programming as you can probably tell.
rhombus