Я получил отчет о сбое от живого пользователя
У меня есть NSObject, который имеет nsstring
@interface MountedVolume : NSObject
@property (nonatomic, strong) NSString *name;
@end
Вид контроллера имеет текстовое поле, значения которого изменяются при уведомлении
получил.
@interface ViewController : NSViewController {
MountedVolume *selectedVolume;
__weak IBOutlet NSTextField *txtVolumeName;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[[NSNotificationCenter defaultCenter] addObserverForName:DCNotificationNameVolumesUpdated object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
dispatch_async(dispatch_get_main_queue(), ^{
//crash report says in this line it got crashed
txtVolumeName.stringValue = selectedVolume.name;
});
}];
}
@end
Ниже приведен отчет о сбое, какие-либо предложения, как с этим бороться?
отчет о сбое
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x7fff6ac2639d objc_msgSend + 29
1 AppKit 0x7fff3db3d868 -[NSCell _objectValue:forString:errorDescription:] + 157
2 AppKit 0x7fff3db3d71d -[NSCell setStringValue:] + 40
3 AppKit 0x7fff3db95044 -[NSControl setStringValue:] + 135
4 MyApp 0x104de865b __40-[ViewController viewDidLoad]_block_invoke_3 (ViewController.m:172)
5 libdispatch.dylib 0x7fff6c3ab5f8 _dispatch_call_block_and_release + 12
6 libdispatch.dylib 0x7fff6c3ac63d _dispatch_client_callout + 8
7 libdispatch.dylib 0x7fff6c3b768d _dispatch_main_queue_callback_4CF + 1135
8 CoreFoundation 0x7fff40435f56 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
9 CoreFoundation 0x7fff40435683 __CFRunLoopRun + 2300
10 CoreFoundation 0x7fff40434b35 CFRunLoopRunSpecific + 459
11 HIToolbox 0x7fff3f71396b RunCurrentEventLoopInMode + 292
12 HIToolbox 0x7fff3f7136a5 ReceiveNextEventCommon + 603
13 HIToolbox 0x7fff3f713436 _BlockUntilNextEventMatchingListInModeWithFilter + 64
14 AppKit 0x7fff3daad987 _DPSNextEvent + 965
15 AppKit 0x7fff3daac71f -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1361
16 AppKit 0x7fff3daa683c -[NSApplication run] + 699
17 AppKit 0x7fff3da95d7c NSApplicationMain + 777
18 libdyld.dylib 0x7fff6c3f93d5 start + 1