Sin descripción

NSDictionary+SafeAccess.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // NSDictionary+SafeAccess.h
  3. // IOS-Categories
  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 (SafeAccess)
  11. - (BOOL)hasKey:(NSString *)key;
  12. - (NSString*)stringForKey:(id)key;
  13. - (NSNumber*)numberForKey:(id)key;
  14. - (NSArray*)arrayForKey:(id)key;
  15. - (NSDictionary*)dictionaryForKey:(id)key;
  16. - (NSInteger)integerForKey:(id)key;
  17. - (NSUInteger)unsignedIntegerForKey:(id)key;
  18. - (BOOL)boolForKey:(id)key;
  19. - (int16_t)int16ForKey:(id)key;
  20. - (int32_t)int32ForKey:(id)key;
  21. - (int64_t)int64ForKey:(id)key;
  22. - (char)charForKey:(id)key;
  23. - (short)shortForKey:(id)key;
  24. - (float)floatForKey:(id)key;
  25. - (double)doubleForKey:(id)key;
  26. - (long long)longLongForKey:(id)key;
  27. - (unsigned long long)unsignedLongLongForKey:(id)key;
  28. //CG
  29. - (CGFloat)CGFloatForKey:(id)key;
  30. - (CGPoint)pointForKey:(id)key;
  31. - (CGSize)sizeForKey:(id)key;
  32. - (CGRect)rectForKey:(id)key;
  33. @end
  34. #pragma --mark NSMutableDictionary setter
  35. @interface NSMutableDictionary(SafeAccess)
  36. -(void)setObj:(id)i forKey:(NSString*)key;
  37. -(void)setString:(NSString*)i forKey:(NSString*)key;
  38. -(void)setBool:(BOOL)i forKey:(NSString*)key;
  39. -(void)setInt:(int)i forKey:(NSString*)key;
  40. -(void)setInteger:(NSInteger)i forKey:(NSString*)key;
  41. -(void)setUnsignedInteger:(NSUInteger)i forKey:(NSString*)key;
  42. -(void)setCGFloat:(CGFloat)f forKey:(NSString*)key;
  43. -(void)setChar:(char)c forKey:(NSString*)key;
  44. -(void)setFloat:(float)i forKey:(NSString*)key;
  45. -(void)setDouble:(double)i forKey:(NSString*)key;
  46. -(void)setLongLong:(long long)i forKey:(NSString*)key;
  47. -(void)setPoint:(CGPoint)o forKey:(NSString*)key;
  48. -(void)setSize:(CGSize)o forKey:(NSString*)key;
  49. -(void)setRect:(CGRect)o forKey:(NSString*)key;
  50. @end