添加HWPanModal和FLAnimatedImage
This commit is contained in:
52
Pods/HWPanModal/Sources/KVO/KeyValueObserver.h
generated
Normal file
52
Pods/HWPanModal/Sources/KVO/KeyValueObserver.h
generated
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// KeyValueObserver.h
|
||||
// Lab Color Space Explorer
|
||||
//
|
||||
// Created by Daniel Eggert on 01/12/2013.
|
||||
// Copyright (c) 2013 objc.io. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
|
||||
@interface KeyValueObserver : NSObject
|
||||
|
||||
@property (nonatomic, weak) id target;
|
||||
@property (nonatomic) SEL selector;
|
||||
|
||||
/// Create a Key-Value Observing helper object.
|
||||
///
|
||||
/// As long as the returned token object is retained, the KVO notifications of the @c object
|
||||
/// and @c keyPath will cause the given @c selector to be called on @c target.
|
||||
/// @a object and @a target are weak references.
|
||||
/// Once the token object gets dealloc'ed, the observer gets removed.
|
||||
///
|
||||
/// The @c selector should conform to
|
||||
/// @code
|
||||
/// - (void)nameDidChange:(NSDictionary *)change;
|
||||
/// @endcode
|
||||
/// The passed in dictionary is the KVO change dictionary (c.f. @c NSKeyValueChangeKindKey, @c NSKeyValueChangeNewKey etc.)
|
||||
///
|
||||
/// @returns the opaque token object to be stored in a property
|
||||
///
|
||||
/// Example:
|
||||
///
|
||||
/// @code
|
||||
/// self.nameObserveToken = [KeyValueObserver observeObject:user
|
||||
/// keyPath:@"name"
|
||||
/// target:self
|
||||
/// selector:@selector(nameDidChange:)];
|
||||
/// @endcode
|
||||
+ (NSObject *)observeObject:(id)object keyPath:(NSString*)keyPath target:(id)target selector:(SEL)selector __attribute__((warn_unused_result));
|
||||
|
||||
/// Create a key-value-observer with the given KVO options
|
||||
+ (NSObject *)observeObject:(id)object keyPath:(NSString*)keyPath target:(id)target selector:(SEL)selector options:(NSKeyValueObservingOptions)options __attribute__((warn_unused_result));
|
||||
|
||||
/**
|
||||
* When you call this method, observer will not work.
|
||||
* Please call observer method again.
|
||||
*/
|
||||
- (void)unObserver;
|
||||
|
||||
@end
|
||||
85
Pods/HWPanModal/Sources/KVO/KeyValueObserver.m
generated
Normal file
85
Pods/HWPanModal/Sources/KVO/KeyValueObserver.m
generated
Normal file
@@ -0,0 +1,85 @@
|
||||
//
|
||||
// KeyValueObserver.m
|
||||
// Lab Color Space Explorer
|
||||
//
|
||||
// Created by Daniel Eggert on 01/12/2013.
|
||||
// Copyright (c) 2013 objc.io. All rights reserved.
|
||||
//
|
||||
|
||||
#import "KeyValueObserver.h"
|
||||
|
||||
//
|
||||
// Created by chris on 7/24/13.
|
||||
//
|
||||
|
||||
#import "KeyValueObserver.h"
|
||||
|
||||
@interface KeyValueObserver ()
|
||||
@property (nonatomic, weak) id observedObject;
|
||||
@property (nonatomic, copy) NSString* keyPath;
|
||||
@property (nonatomic, assign) BOOL shouldObserver;
|
||||
@end
|
||||
|
||||
@implementation KeyValueObserver
|
||||
|
||||
- (id)initWithObject:(id)object keyPath:(NSString*)keyPath target:(id)target selector:(SEL)selector options:(NSKeyValueObservingOptions)options;
|
||||
{
|
||||
if (object == nil) {
|
||||
return nil;
|
||||
}
|
||||
NSParameterAssert(target != nil);
|
||||
NSParameterAssert([target respondsToSelector:selector]);
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_shouldObserver = YES;
|
||||
self.target = target;
|
||||
self.selector = selector;
|
||||
self.observedObject = object;
|
||||
self.keyPath = keyPath;
|
||||
[object addObserver:self forKeyPath:keyPath options:options context:(__bridge void *)(self)];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSObject *)observeObject:(id)object keyPath:(NSString*)keyPath target:(id)target selector:(SEL)selector __attribute__((warn_unused_result));
|
||||
{
|
||||
return [self observeObject:object keyPath:keyPath target:target selector:selector options:0];
|
||||
}
|
||||
|
||||
+ (NSObject *)observeObject:(id)object keyPath:(NSString*)keyPath target:(id)target selector:(SEL)selector options:(NSKeyValueObservingOptions)options __attribute__((warn_unused_result));
|
||||
{
|
||||
return [[self alloc] initWithObject:object keyPath:keyPath target:target selector:selector options:options];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change context:(void*)context
|
||||
{
|
||||
if (context == (__bridge void *)(self)) {
|
||||
[self didChange:change];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didChange:(NSDictionary *)change {
|
||||
|
||||
if (!self.shouldObserver) {
|
||||
return;
|
||||
}
|
||||
|
||||
id strongTarget = self.target;
|
||||
|
||||
if ([strongTarget respondsToSelector:self.selector]) {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
|
||||
[strongTarget performSelector:self.selector withObject:change];
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[self.observedObject removeObserver:self forKeyPath:self.keyPath];
|
||||
}
|
||||
|
||||
- (void)unObserver {
|
||||
self.shouldObserver = NO;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user