Skip to content

Commit

Permalink
Litter modify
Browse files Browse the repository at this point in the history
Litter modify
  • Loading branch information
CoderMJLee committed Sep 14, 2015
1 parent 45ac7f6 commit b204c2d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
1 change: 0 additions & 1 deletion MJExtension/MJFoundation.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ + (BOOL)isClassFromFoundation:(Class)c

__block BOOL result = NO;
[[self foundationClasses] enumerateObjectsUsingBlock:^(Class foundationClass, BOOL *stop) {
// isSubclassOfClass已经包含了是本类的情况了
if ([c isSubclassOfClass:foundationClass]) {
result = YES;
*stop = YES;
Expand Down
19 changes: 6 additions & 13 deletions MJExtension/MJProperty.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,12 @@ - (NSMutableDictionary *)objectClassInArrayDict
#pragma mark - 缓存
+ (instancetype)cachedPropertyWithProperty:(objc_property_t)property
{
// 每个属性中的objc_property_t都代表不同的地址,也就是说,即使属性名,属性类型相同,地址也是不一样的
// 所以,objc_getAssociatedObject得到的对象总为空

// MJProperty *propertyObj = objc_getAssociatedObject(self, property);
// if (propertyObj == nil) {
// propertyObj = [[self alloc] init];
// propertyObj.property = property;
// objc_setAssociatedObject(self, property, propertyObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
// }


MJProperty *propertyObj = [[self alloc] init];
propertyObj.property = property;
MJProperty *propertyObj = objc_getAssociatedObject(self, property);
if (propertyObj == nil) {
propertyObj = [[self alloc] init];
propertyObj.property = property;
objc_setAssociatedObject(self, property, propertyObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return propertyObj;
}

Expand Down
2 changes: 0 additions & 2 deletions MJExtension/MJPropertyType.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ - (void)setCode:(NSString *)code
_code = [code substringWithRange:NSMakeRange(2, code.length - 3)];
_typeClass = NSClassFromString(_code);
_fromFoundation = [MJFoundation isClassFromFoundation:_typeClass];

// isSubclassOfClass已经包含了是本类的情况了
_numberType = [_typeClass isSubclassOfClass:[NSNumber class]];

} else if ([code isEqualToString:MJPropertyTypeSEL] ||
Expand Down
Binary file not shown.

0 comments on commit b204c2d

Please sign in to comment.