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
@interface NSObject () | |
- (void)_addObserver:(id)arg1 forProperty:(id)arg2 options:(unsigned int)arg3 context:(void*)arg4; | |
- (void)_changeValueForKey:(id)arg1 key:(id)arg2 key:(id)arg3 usingBlock:(id /* block */)arg4; | |
- (void)_changeValueForKey:(id)arg1 usingBlock:(id /* block */)arg2; | |
- (void)_changeValueForKeys:(id*)arg1 count:(unsigned int)arg2 maybeOldValuesDict:(id)arg3 usingBlock:(id /* block */)arg4; | |
- (void)_didChangeValuesForKeys:(id)arg1; | |
- (void)_notifyObserversForKeyPath:(id)arg1 change:(id)arg2; | |
- (void)_notifyObserversOfChangeFromValuesForKeys:(id)arg1 toValuesForKeys:(id)arg2; | |
- (void)_willChangeValuesForKeys:(id)arg1; | |
@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
/* 2016-12-05 19:29:16.988026 Compass[71668:644974] [General] An uncaught exception was raised | |
2016-12-05 19:29:16.988060 Compass[71668:644974] [General] Cannot update for observer <TestObserver 0x600000001060> for the key path "nestedObject.nestedField" from <TestObject 0x600000026ee0>, most likely because the value for the key "nestedObject" has changed without an appropriate KVO notification being sent. Check the KVO-compliance of the TestObject class. | |
2016-12-05 19:29:16.988395 Compass[71668:644974] [General] ( | |
0 CoreFoundation 0x00007fffaa71ee7b __exceptionPreprocess + 171 | |
1 libobjc.A.dylib 0x00007fffbf303cad objc_exception_throw + 48 | |
2 CoreFoundation 0x00007fffaa79d99d +[NSException raise:format:] + 205 | |
3 Foundation 0x00007fffac0f5a62 -[NSKeyValueNestedProperty object:withObservance:didChangeValueForKeyOrKeys:recurse:forwardingValues:] + 830 | |
4 Foundation 0x00007fffac0c8e88 NSKe |
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
public extension SignalProducerType { | |
func toRACSignal() -> RACSignal { | |
let signal = RACSignal.createSignal { subscriber in | |
let disposable = self.start { | |
switch $0 { | |
case let .Next(value): | |
guard let value = deepUnwrap(value) else { | |
subscriber.sendNext(nil) | |
break | |
} |
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
#import <Foundation/Foundation.h> | |
// VARIABLE must be a variable declaration (NSString *foo) | |
// VALUE is what you are checking is not nil | |
// WHERE is an additional BOOL condition | |
#define iflet(VARIABLE, VALUE) \ | |
ifletwhere(VARIABLE, VALUE, YES) | |
#define ifletwhere(VARIABLE, VALUE, WHERE) \ |
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
func caseLabelForEnum(enumm: Any) -> String { | |
let mirror = Mirror(reflecting: enumm) | |
return mirror.children.first?.label ?? String(enumm) | |
} | |
func associatedValueForEnum(enumm: Any) -> Any? { | |
let mirror = Mirror(reflecting: enumm) | |
return mirror.children.first?.value |
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
func ensureType<T>(type type: T.Type = T.self, transform: (Any) -> T)(_ any: Any) -> T { | |
return ensureType(any, type: type, transform: transform) | |
} | |
func ensureType<T>(any: Any, type: T.Type = T.self, transform: (Any) -> T) -> T { | |
if let any = any as? T { | |
return any | |
} else { | |
return transform(any) | |
} |
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
func deepDescription(any: Any) -> String { | |
guard let any = deepUnwrap(any) else { | |
return "nil" | |
} | |
if any is Void { | |
return "Void" | |
} | |
if let int = any as? Int { |
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
func deepUnwrap(any: Any) -> Any? { | |
let mirror = Mirror(reflecting: any) | |
if mirror.displayStyle != .Optional { | |
return any | |
} | |
if let child = mirror.children.first where child.label == "Some" { | |
return deepUnwrap(child.value) | |
} |
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
func asDictionary<K, V>(any: Any, type: (key: K.Type, value: V.Type) = (K.self, V.self)) -> [K: V]? { | |
let mirror = Mirror(reflecting: any) | |
let properties = mirror.children | |
guard let displayStyle = mirror.displayStyle where displayStyle == .Dictionary else { | |
return nil | |
} | |
var dictionary = [K: V]() |
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
func asArray<T>(any: Any, type: T.Type = T.self) -> [T]? { | |
let mirror = Mirror(reflecting: any) | |
let properties = Array(mirror.children) | |
guard let displayStyle = mirror.displayStyle where (displayStyle == .Collection || displayStyle == .Set || displayStyle == .Tuple) else { | |
return nil | |
} | |
var array = [T]() |
NewerOlder