Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Use NSKeyValueChangeKey instead of NSString for change dictionary key…
Browse files Browse the repository at this point in the history
… type (#124)
  • Loading branch information
mohamede1945 authored and nlutsenko committed Mar 11, 2017
1 parent aea880a commit 09be0e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion FBKVOController/FBKVOController.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ extern NSString *const FBKVONotificationKeyPathKey;
@param object The object changed.
@param change The change dictionary which also includes @c FBKVONotificationKeyPathKey
*/
typedef void (^FBKVONotificationBlock)(id _Nullable observer, id object, NSDictionary<NSString *, id> *change);
typedef void (^FBKVONotificationBlock)(id _Nullable observer, id object, NSDictionary<NSKeyValueChangeKey, id> *change);

/**
@abstract FBKVOController makes Key-Value Observing simpler and safer.
Expand Down
4 changes: 2 additions & 2 deletions FBKVOController/FBKVOController.m
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ - (void)unobserve:(id)object infos:(nullable NSSet<_FBKVOInfo *> *)infos

- (void)observeValueForKeyPath:(nullable NSString *)keyPath
ofObject:(nullable id)object
change:(nullable NSDictionary<NSString *, id> *)change
change:(nullable NSDictionary<NSKeyValueChangeKey, id> *)change
context:(nullable void *)context
{
NSAssert(context, @"missing context keyPath:%@ object:%@ change:%@", keyPath, object, change);
Expand All @@ -374,7 +374,7 @@ - (void)observeValueForKeyPath:(nullable NSString *)keyPath

// dispatch custom block or action, fall back to default action
if (info->_block) {
NSDictionary<NSString *, id> *changeWithKeyPath = change;
NSDictionary<NSKeyValueChangeKey, id> *changeWithKeyPath = change;
// add the keyPath to the change dictionary for clarity when mulitple keyPaths are being observed
if (keyPath) {
NSMutableDictionary<NSString *, id> *mChange = [NSMutableDictionary dictionaryWithObject:keyPath forKey:FBKVONotificationKeyPathKey];
Expand Down

0 comments on commit 09be0e5

Please sign in to comment.