mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-05-30 18:03:59 +08:00
Fixed a number of memory leaks. Added ability to cancel requests. Optimized the property inspector with cacheing. Much improved performance!
This commit is contained in:
@@ -12,6 +12,19 @@
|
||||
|
||||
@implementation RKObjectPropertyInspector
|
||||
|
||||
- (id)init {
|
||||
if (self = [super init]) {
|
||||
_cachedPropertyNamesAndTypes = [[NSMutableDictionary alloc] init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_cachedPropertyNamesAndTypes release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString*)propertyTypeFromAttributeString:(NSString*)attributeString {
|
||||
NSString *type = [NSString string];
|
||||
NSScanner *typeScanner = [NSScanner scannerWithString:attributeString];
|
||||
@@ -28,7 +41,11 @@
|
||||
}
|
||||
|
||||
- (NSDictionary *)propertyNamesAndTypesForClass:(Class)class {
|
||||
NSMutableDictionary *propertyNames = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary* propertyNames = [_cachedPropertyNamesAndTypes objectForKey:class];
|
||||
if (propertyNames) {
|
||||
return propertyNames;
|
||||
}
|
||||
propertyNames = [NSMutableDictionary dictionary];
|
||||
|
||||
//include superclass properties
|
||||
Class currentClass = class;
|
||||
@@ -61,6 +78,8 @@
|
||||
free(propList);
|
||||
currentClass = [currentClass superclass];
|
||||
}
|
||||
|
||||
[_cachedPropertyNamesAndTypes setObject:propertyNames forKey:class];
|
||||
return propertyNames;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user