NSObject+SafeExpectations
从 NSDictionary
中获取意外值不再会导致崩溃。
使用方法
为 NSDictionary
提供了几种新的方法:请参阅 文档
- (NSString *)stringForKey:(id)key;
- (NSNumber *)numberForKey:(id)key;
- (NSArray *)arrayForKey:(id)key;
- (NSDictionary *)dictionaryForKey:(id)key;
- (id)objectForKeyPath:(NSString *)keyPath;
- (NSString *)stringForKeyPath:(id)keyPath;
- (NSNumber *)numberForKeyPath:(id)keyPath;
- (NSArray *)arrayForKeyPath:(id)keyPath;
- (NSDictionary *)dictionaryForKeyPath:(id)keyPath;
愿望列表
NSArray
:stringAtIndex:
、numberAtIndex:
、arrayAtIndex:
、dictionaryAtIndex:
- 为
objectForKeyPath:
提供集合支持