mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 13:10:59 +00:00
Add decoding of binding options and handle bindings to arrays
with transformations correctly.
This commit is contained in:
parent
00bb2396a6
commit
50bc834ddc
3 changed files with 23 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
2020-01-19 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/GSXib5KeyedUnarchiver.m: Handle dictionary elements correctly.
|
||||
* Source/NSKeyValueBinding.m: Transform each element of an array.
|
||||
|
||||
2020-01-18 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSArrayController.m: Only filter if there is a filter predicate.
|
||||
|
|
|
@ -888,7 +888,8 @@ didStartElement: (NSString*)elementName
|
|||
{
|
||||
if ([NSClassFromString(className) isSubclassOfClass: [NSArray class]])
|
||||
elementType = @"array";
|
||||
else if ([@"string" isEqualToString: elementName] == NO)
|
||||
else if (([@"string" isEqualToString: elementName] == NO) &&
|
||||
([@"dictionary" isEqualToString: elementName] == NO))
|
||||
elementType = @"object";
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
#import "AppKit/NSKeyValueBinding.h"
|
||||
#import "GSBindingHelpers.h"
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
@implementation NSObject (NSKeyValueBindingCreation)
|
||||
|
||||
|
@ -450,7 +451,21 @@ void GSBindingInvokeAction(NSString *targetKey, NSString *argumentKey,
|
|||
|
||||
if (valueTransformer != nil)
|
||||
{
|
||||
value = [valueTransformer transformedValue: value];
|
||||
if ([value isKindOfClass: [NSArray class]])
|
||||
{
|
||||
NSArray *oldValue = (NSArray *)value;
|
||||
NSMutableArray *newValue = [[NSMutableArray alloc] initWithCapacity: [oldValue count]];
|
||||
id<NSFastEnumeration> enumerator = oldValue;
|
||||
|
||||
FOR_IN (id, obj, enumerator)
|
||||
[newValue addObject: [valueTransformer transformedValue: obj]];
|
||||
END_FOR_IN(enumerator)
|
||||
value = AUTORELEASE(newValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = [valueTransformer transformedValue: value];
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
|
|
Loading…
Reference in a new issue