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:
Blake Watters
2010-03-11 12:19:18 -05:00
parent db87576d79
commit 3c5fda2dee
12 changed files with 70 additions and 16 deletions

View File

@@ -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;
}