NSMutableArray+RQExtension.m 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //
  2. // NSMutableArray+proper.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/11/18.
  6. // Copyright (c) 2015年 JCZ. All rights reserved.
  7. //
  8. #import "NSMutableArray+RQExtension.h"
  9. @implementation NSMutableArray(RQExtension)
  10. -(void)property:(id)obj forKey:(NSString*)key
  11. {
  12. if (self)
  13. {
  14. if (!obj) {
  15. obj = @"";
  16. }
  17. if (!key) {
  18. key = @"";
  19. }
  20. NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:obj,key, nil];
  21. [self addObject:dict];
  22. }
  23. }
  24. -(void)addPro:(NSString*)name Value:(NSString*)value
  25. {
  26. [self property:value forKey:name];
  27. }
  28. -(void)addPro2:(NSString*)name Value:(id)value
  29. {
  30. [self property:value forKey:name];
  31. }
  32. @end
  33. @implementation NSArray(RQExtension)
  34. -(id)objAtPath:(NSIndexPath*)path
  35. {
  36. if (path.section < self.count ) {
  37. NSArray* subObj = self[path.section];
  38. if([subObj isKindOfClass:[NSArray class]] ||
  39. [subObj isKindOfClass:[NSMutableArray class]])
  40. {
  41. if (path.row < subObj.count) {
  42. return [self[path.section] objectAtIndex:path.row];
  43. }
  44. }
  45. }
  46. return nil;
  47. }
  48. @end