MJPropertyKey.m 648 B

12345678910111213141516171819202122232425
  1. //
  2. // MJPropertyKey.m
  3. // MJExtensionExample
  4. //
  5. // Created by MJ Lee on 15/8/11.
  6. // Copyright (c) 2015年 小码哥. All rights reserved.
  7. //
  8. #import "MJPropertyKey.h"
  9. @implementation MJPropertyKey
  10. - (id)valueInObject:(id)object
  11. {
  12. if ([object isKindOfClass:[NSDictionary class]] && self.type == MJPropertyKeyTypeDictionary) {
  13. return object[self.name];
  14. } else if ([object isKindOfClass:[NSArray class]] && self.type == MJPropertyKeyTypeArray) {
  15. NSArray *array = object;
  16. NSUInteger index = self.name.intValue;
  17. if (index < array.count) return array[index];
  18. return nil;
  19. }
  20. return nil;
  21. }
  22. @end