Skip to content

Commit

Permalink
Add method _keyPathForValueBinding in _setObjectValue for table view
Browse files Browse the repository at this point in the history
  • Loading branch information
gcasa committed Aug 21, 2024
1 parent 1a188b7 commit 068684d
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions Source/NSTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ @interface NSTableColumn (Private)
- (NSArray *) _prototypeCellViews;
- (void) _applyBindingsToCell: (NSCell *)cell
atRow: (NSInteger)index;
- (NSString *) _keyPathForValueBinding;
@end

/*
Expand Down Expand Up @@ -6831,28 +6832,17 @@ - (void) _setObjectValue: (id)value
forTableColumn: (NSTableColumn *)tb
row: (NSInteger) index
{
GSKeyValueBinding *theBinding;

theBinding = [GSKeyValueBinding getBinding: NSValueBinding
forObject: tb];
if (theBinding != nil)
NSString *keyPath = [tb _keyPathForValueBinding];
if (keyPath != nil)
{
NSArray *items = [[theBinding observedObject] arrangedObjects];
if (items != nil)
{
NSDictionary *info = [GSKeyValueBinding infoForBinding: NSValueBinding
forObject: tb];
if (info != nil)
{
NSString *ikp = [info objectForKey: NSObservedKeyPathKey];
NSUInteger location = [ikp rangeOfString: @"."].location;
NSString *keyPath = (location == NSNotFound ? ikp : [ikp substringFromIndex: location + 1]);
id obj = [items objectAtIndex: index];
id obj = [items objectAtIndex: index];

if (obj != nil)
{
[obj setValue: value forKeyPath: keyPath];
}
if (obj != nil)
{
[obj setValue: value forKeyPath: keyPath];
}
}
}
Expand Down

0 comments on commit 068684d

Please sign in to comment.