Objective c 在线程中调用NSPathControl对象时崩溃
出于某种原因,在线程中调用NSPathControl对象会导致崩溃Objective c 在线程中调用NSPathControl对象时崩溃,objective-c,crash,multithreading,Objective C,Crash,Multithreading,出于某种原因,在线程中调用NSPathControl对象会导致崩溃 - (IBAction) action5:(id)sender { [outlet_NSPathControl1 setURL: [NSURL fileURLWithPath: @"/Users/admin/"]]; // Works fine here [self performSelectorInBackground:@selector(background1) withObject:self]; // Jump to
- (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];
}
“Crash”的描述还不足以提供任何特定的帮助,但是如果一个类没有被列为线程安全的,那么它可能就不是
UI元素通常也只能从主线程更新 谢谢你提供的信息。正如你可能知道的那样,我是Mac编程新手。