开发者

Calling NSPathControl object in thread crashes

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)开发者_JAVA百科 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];
}


"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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜