-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major improvements and additions to KVO helpers
- Loading branch information
1 parent
33005b0
commit ee11343
Showing
6 changed files
with
107 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// NSObject+ParseHelpersKVO.h | ||
// ParseHelpers | ||
// | ||
// Created by Maxim Khatskevich on 30/03/15. | ||
// Copyright (c) 2015 Maxim Khatsevich. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
//=== | ||
|
||
@interface NSObject (ParseHelpersKVO) | ||
|
||
- (void)observeParseObject:(id)targetObject withHandler:(void(^)(id object))changeHandler; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// NSObject+ParseHelpersKVO.m | ||
// ParseHelpers | ||
// | ||
// Created by Maxim Khatskevich on 30/03/15. | ||
// Copyright (c) 2015 Maxim Khatsevich. All rights reserved. | ||
// | ||
|
||
#import "NSObject+ParseHelpersKVO.h" | ||
|
||
#import "NSObject+FBKVOController.h" | ||
#import "MKHMacros.h" | ||
#import "NSObject+MKHGenericHelpers.h" | ||
#import <Parse/Parse.h> | ||
|
||
//=== | ||
|
||
@implementation NSObject (ParseHelpersKVO) | ||
|
||
- (void)observeParseObject:(id)targetObject withHandler:(void(^)(id object))changeHandler | ||
{ | ||
if ([PFObject isClassOfObject:targetObject] && changeHandler) | ||
{ | ||
PFObject *parseObject = (PFObject *)targetObject; | ||
|
||
//=== | ||
|
||
[self.KVOController | ||
observe:parseObject | ||
keyPath:MKH_selectorStr(updatedAt) | ||
options:NSKeyValueObservingOptionInitial|NSKeyValueObservingOptionNew | ||
block:^(id observer, id object, NSDictionary *change) { | ||
|
||
if (parseObject.isDataAvailable) | ||
{ | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
|
||
changeHandler(parseObject); | ||
}); | ||
} | ||
}]; | ||
} | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// ParseHelpersKVO.h | ||
// ParseHelpers | ||
// | ||
// Created by Maxim Khatskevich on 30/03/15. | ||
// Copyright (c) 2015 Maxim Khatsevich. All rights reserved. | ||
// | ||
|
||
#ifndef ParseHelpers_ParseHelpersKVO_h | ||
#define ParseHelpers_ParseHelpersKVO_h | ||
|
||
|
||
|
||
#endif |