Move handling of dictionary creation into GSControllerTreeProxy class, per discussion with @fredkiefer

This commit is contained in:
Gregory John Casamento 2024-07-27 18:51:59 -04:00
parent abfc782a6c
commit 6f2c542b46
3 changed files with 19 additions and 14 deletions

View file

@ -40,8 +40,9 @@ extern "C" {
+ (NSMutableDictionary *) dictionaryWithChildren: (NSMutableArray *)children;
- (instancetype) initWithRepresentedObject: (id)representedObject
withController: (id)controller;
- (instancetype) initWithContent: (id)content
withController: (id)controller;
- (NSUInteger) count;
- (NSMutableArray *) children;

View file

@ -35,19 +35,21 @@
+ (NSMutableDictionary *) dictionaryWithChildren: (NSMutableArray *)children
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithObject: children
forKey: @"children"];
return dictionary;
return [NSMutableDictionary dictionaryWithObject: children
forKey: @"children"];
}
- (instancetype) initWithRepresentedObject: (id)representedObject
withController: (id)controller
- (instancetype) initWithContent: (id)content
withController: (id)controller
{
self = [super initWithRepresentedObject: representedObject];
self = [super initWithRepresentedObject:
[GSControllerTreeProxy
dictionaryWithChildren: content]];
if (self != nil)
{
ASSIGN(_controller, controller);
}
return self;
}

View file

@ -192,9 +192,8 @@
if ([_content isKindOfClass: [NSArray class]])
{
NSMutableDictionary *dictionary = [GSControllerTreeProxy dictionaryWithChildren: _content];
_arranged_objects = [[GSControllerTreeProxy alloc] initWithRepresentedObject: dictionary
withController: self];
_arranged_objects = [[GSControllerTreeProxy alloc] initWithContent: _content
withController: self];
}
[self didChangeValueForKey: @"arrangedObjects"];
@ -278,8 +277,8 @@
{
NSMutableArray *newContent = [NSMutableArray arrayWithArray: [self content]];
GSControllerTreeProxy *node = [[GSControllerTreeProxy alloc]
initWithRepresentedObject: newObject
withController: self];
initWithContent: newObject
withController: self];
[newContent addObject: node];
@ -294,7 +293,10 @@
NSIndexPath *p = [self selectionIndexPath];
id newObject = [self newObject];
[self insertObject: newObject atArrangedObjectIndexPath: p];
if (p != nil)
{
[self insertObject: newObject atArrangedObjectIndexPath: p];
}
}
- (IBAction) remove: (id)sender