NSDictionary+JKSafeAccess.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //
  2. // NSDictionary+JKSafeAccess.h
  3. // JKCategories (https://github.com/shaojiankui/JKCategories)
  4. //
  5. // Created by Jakey on 15/1/25.
  6. // Copyright (c) 2015年 www.skyfox.org. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. @interface NSDictionary (JKSafeAccess)
  11. //- (BOOL)jk_hasKey:(NSString *)key;
  12. - (NSString*)jk_stringForKey:(id)key;
  13. - (NSNumber*)jk_numberForKey:(id)key;
  14. - (NSDecimalNumber *)jk_decimalNumberForKey:(id)key;
  15. - (NSArray*)jk_arrayForKey:(id)key;
  16. - (NSDictionary*)jk_dictionaryForKey:(id)key;
  17. - (NSInteger)jk_integerForKey:(id)key;
  18. - (NSUInteger)jk_unsignedIntegerForKey:(id)key;
  19. - (BOOL)jk_boolForKey:(id)key;
  20. - (int16_t)jk_int16ForKey:(id)key;
  21. - (int32_t)jk_int32ForKey:(id)key;
  22. - (int64_t)jk_int64ForKey:(id)key;
  23. - (char)jk_charForKey:(id)key;
  24. - (short)jk_shortForKey:(id)key;
  25. - (float)jk_floatForKey:(id)key;
  26. - (double)jk_doubleForKey:(id)key;
  27. - (long long)jk_longLongForKey:(id)key;
  28. - (unsigned long long)jk_unsignedLongLongForKey:(id)key;
  29. - (NSDate *)jk_dateForKey:(id)key dateFormat:(NSString *)dateFormat;
  30. //CG
  31. - (CGFloat)jk_CGFloatForKey:(id)key;
  32. - (CGPoint)jk_pointForKey:(id)key;
  33. - (CGSize)jk_sizeForKey:(id)key;
  34. - (CGRect)jk_rectForKey:(id)key;
  35. @end
  36. #pragma --mark NSMutableDictionary setter
  37. @interface NSMutableDictionary(SafeAccess)
  38. -(void)jk_setObj:(id)i forKey:(NSString*)key;
  39. -(void)jk_setString:(NSString*)i forKey:(NSString*)key;
  40. -(void)jk_setBool:(BOOL)i forKey:(NSString*)key;
  41. -(void)jk_setInt:(int)i forKey:(NSString*)key;
  42. -(void)jk_setInteger:(NSInteger)i forKey:(NSString*)key;
  43. -(void)jk_setUnsignedInteger:(NSUInteger)i forKey:(NSString*)key;
  44. -(void)jk_setCGFloat:(CGFloat)f forKey:(NSString*)key;
  45. -(void)jk_setChar:(char)c forKey:(NSString*)key;
  46. -(void)jk_setFloat:(float)i forKey:(NSString*)key;
  47. -(void)jk_setDouble:(double)i forKey:(NSString*)key;
  48. -(void)jk_setLongLong:(long long)i forKey:(NSString*)key;
  49. -(void)jk_setPoint:(CGPoint)o forKey:(NSString*)key;
  50. -(void)jk_setSize:(CGSize)o forKey:(NSString*)key;
  51. -(void)jk_setRect:(CGRect)o forKey:(NSString*)key;
  52. @end