Post

Replies

Boosts

Views

Activity

Crash in NSDictionaryController -addObject:
Consider the following code fragments: @property (readonly) NSDictionaryController *loggedConfigsController; _loggedConfigs = NSMutableDictionary.dictionary; _loggedConfigsController = [NSDictionaryController.alloc initWithContent:self.loggedConfigs]; _loggedConfigsController.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"value" ascending:YES]]; _loggedConfigsController.preservesSelection = YES; _loggedConfigsController.avoidsEmptySelection = YES; _loggedConfigsController.selectsInsertedObjects = NO; _loggedConfigsController.automaticallyRearrangesObjects = YES; - (void)logEventWithTitle:(NSString *)title ident:(p_ident_t)ident { // called from main queue and dispatch queues NSString *identString = [self identStringForIdent:ident]; NSNumber *dictIdent = self.loggedConfigs[identString]; if (dictIdent == nil) { NSDictionaryControllerKeyValuePair *c = self.loggedConfigsController.newObject; c.key = identString; c.value = title; [self.loggedConfigsController addObject:c];// crash } } Crash log: Thread 4 Crashed:: Dispatch queue: Pinger #9 0 libobjc.A.dylib 0x7ff81bb7fcc3 objc_retain + 35 1 AppKit 0x7ff81f18d831 -[NSArrayController _setObjects:] + 49 2 AppKit 0x7ff81f18e502 -[NSArrayController _arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis:] + 365 Does anyone know why -addObject: fails? Any help is appreciated. Thanks in advance!
1
0
656
Mar ’23