mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +00:00
* Headers/Foundation/NSKeyValueObserving.h,
* Source/NSKeyValueObserving.m: Add method -keyPathsForValuesAffectingValueForKey:. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37636 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
11cf284722
commit
e384821ba8
3 changed files with 42 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2014-01-26 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/Foundation/NSKeyValueObserving.h,
|
||||||
|
* Source/NSKeyValueObserving.m: Add method
|
||||||
|
-keyPathsForValuesAffectingValueForKey:.
|
||||||
|
|
||||||
2014-01-25 Frederik <ego@frederikseiffert.de>
|
2014-01-25 Frederik <ego@frederikseiffert.de>
|
||||||
|
|
||||||
* Source/NSKeyValueObserving.m: When using
|
* Source/NSKeyValueObserving.m: When using
|
||||||
|
|
|
@ -202,7 +202,6 @@ GS_EXPORT NSString *const NSKeyValueChangeNotificationIsPriorKey;
|
||||||
* These methods permit modifications to the observing system.
|
* These methods permit modifications to the observing system.
|
||||||
*/
|
*/
|
||||||
@interface NSObject(NSKeyValueObservingCustomization)
|
@interface NSObject(NSKeyValueObservingCustomization)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether the class should send the notification methods of
|
* Specifies whether the class should send the notification methods of
|
||||||
* the NSKeyValueObserverNotification protocol when instances of the
|
* the NSKeyValueObserverNotification protocol when instances of the
|
||||||
|
@ -219,6 +218,15 @@ GS_EXPORT NSString *const NSKeyValueChangeNotificationIsPriorKey;
|
||||||
+ (void) setKeys: (NSArray*)triggerKeys
|
+ (void) setKeys: (NSArray*)triggerKeys
|
||||||
triggerChangeNotificationsForDependentKey: (NSString*)dependentKey;
|
triggerChangeNotificationsForDependentKey: (NSString*)dependentKey;
|
||||||
|
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
|
||||||
|
/**
|
||||||
|
* Returns a set of key paths for properties whose values affect the value
|
||||||
|
* of the specified dependentKey.
|
||||||
|
*/
|
||||||
|
+ (NSSet*) keyPathsForValuesAffectingValueForKey: (NSString*)dependentKey;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the observation information for the receiver
|
* Returns a reference to the observation information for the receiver
|
||||||
* as stored using the -setObservationInfo: method.<br />
|
* as stored using the -setObservationInfo: method.<br />
|
||||||
|
|
|
@ -2016,6 +2016,32 @@ triggerChangeNotificationsForDependentKey: (NSString*)dependentKey
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (NSSet*) keyPathsForValuesAffectingValueForKey: (NSString*)dependentKey
|
||||||
|
{
|
||||||
|
NSString *selString = [NSString stringWithFormat: @"keyPathsForValuesAffecting%@",
|
||||||
|
dependentKey];
|
||||||
|
SEL sel = NSSelectorFromString(selString);
|
||||||
|
NSMapTable *affectingKeys;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSString *affectingKey;
|
||||||
|
NSMutableSet *keyPaths;
|
||||||
|
|
||||||
|
if ([self respondsToSelector: sel])
|
||||||
|
{
|
||||||
|
return [self performSelector: sel];
|
||||||
|
}
|
||||||
|
|
||||||
|
affectingKeys = NSMapGet(dependentKeyTable, self);
|
||||||
|
keyPaths = [[NSMutableSet alloc] initWithCapacity: [affectingKeys count]];
|
||||||
|
enumerator = [affectingKeys keyEnumerator];
|
||||||
|
while ((affectingKey = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
[keyPaths addObject: affectingKey];
|
||||||
|
}
|
||||||
|
|
||||||
|
return AUTORELEASE(keyPaths);
|
||||||
|
}
|
||||||
|
|
||||||
- (void*) observationInfo
|
- (void*) observationInfo
|
||||||
{
|
{
|
||||||
void *info;
|
void *info;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue