mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Fixing retain cycle issues found by Mark Krenek (markkrenek@mac.com)
This commit is contained in:
@@ -110,6 +110,7 @@ static RKClient* sharedClient = nil;
|
||||
- (RKRequest*)requestWithResourcePath:(NSString*)resourcePath delegate:(id)delegate callback:(SEL)callback {
|
||||
RKRequest* request = [[RKRequest alloc] initWithURL:[self URLForResourcePath:resourcePath] delegate:delegate callback:callback];
|
||||
[self setupRequest:request];
|
||||
[request autorelease];
|
||||
|
||||
return request;
|
||||
}
|
||||
@@ -121,6 +122,7 @@ static RKClient* sharedClient = nil;
|
||||
- (RKRequest*)load:(NSString*)resourcePath method:(RKRequestMethod)method params:(NSObject<RKRequestSerializable>*)params delegate:(id)delegate callback:(SEL)callback {
|
||||
RKRequest* request = [[RKRequest alloc] initWithURL:[self URLForResourcePath:resourcePath] delegate:delegate callback:callback];
|
||||
[self setupRequest:request];
|
||||
[request autorelease];
|
||||
request.params = params;
|
||||
request.method = method;
|
||||
[request send];
|
||||
|
||||
@@ -40,9 +40,8 @@
|
||||
- (void)dealloc {
|
||||
[_mapper release];
|
||||
[_request release];
|
||||
[_delegate release];
|
||||
[_response release];
|
||||
[_fetchRequest release];
|
||||
[_fetchRequest release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@@ -121,7 +120,6 @@
|
||||
}
|
||||
|
||||
- (void)informDelegateOfObjectLoadWithInfoDictionary:(NSDictionary*)dictionary {
|
||||
RKResponse* response = [dictionary objectForKey:@"response"];
|
||||
NSArray* models = [dictionary objectForKey:@"models"];
|
||||
[dictionary release];
|
||||
|
||||
@@ -138,13 +136,9 @@
|
||||
}
|
||||
|
||||
[_delegate objectLoader:self didLoadObjects:[NSArray arrayWithArray:objects]];
|
||||
|
||||
// Release the response now that we have finished all our processing
|
||||
[response release];
|
||||
}
|
||||
|
||||
- (void)informDelegateOfObjectLoadErrorWithInfoDictionary:(NSDictionary*)dictionary {
|
||||
RKResponse* response = [dictionary objectForKey:@"response"];
|
||||
NSError* error = [dictionary objectForKey:@"error"];
|
||||
[dictionary release];
|
||||
|
||||
@@ -156,9 +150,6 @@
|
||||
NSError *rkError = [NSError errorWithDomain:RKRestKitErrorDomain code:RKObjectLoaderRemoteSystemError userInfo:userInfo];
|
||||
|
||||
[_delegate objectLoader:self didFailWithError:rkError];
|
||||
|
||||
// Release the response now that we have finished all our processing
|
||||
[response release];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ static const NSString* kRKModelMapperMappingFormatParserKey = @"RKMappingFormatP
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Can I make this support keyPath??
|
||||
- (id)mapObjectFromDictionary:(NSDictionary*)dictionary {
|
||||
NSString* elementName = [[dictionary allKeys] objectAtIndex:0];
|
||||
Class class = [_elementToClassMappings objectForKey:elementName];
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
- (id)initWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback {
|
||||
if (self = [self initWithURL:URL]) {
|
||||
_delegate = [delegate retain];
|
||||
_delegate = delegate;
|
||||
_callback = callback;
|
||||
}
|
||||
|
||||
@@ -43,10 +43,11 @@
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
[_connection cancel];
|
||||
[_connection release];
|
||||
[_userData release];
|
||||
[_URL release];
|
||||
[_URLRequest release];
|
||||
[_delegate release];
|
||||
[_params release];
|
||||
[_additionalHTTPHeaders release];
|
||||
[_username release];
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
* If this object implements life-cycle methods from the RKRequestDelegate protocol,
|
||||
* events from the request will be forwarded back.
|
||||
*/
|
||||
@property (nonatomic, retain) NSObject<RKObjectLoaderDelegate>* delegate;
|
||||
@property (nonatomic, assign) NSObject<RKObjectLoaderDelegate>* delegate;
|
||||
|
||||
/**
|
||||
* The underlying request object for this loader
|
||||
|
||||
@@ -75,6 +75,7 @@ typedef enum {
|
||||
* Register a mapping for a given class for an XML element with the given tag name
|
||||
* will blow up if the class does not respond to elementToPropertyMappings and elementToRelationshipMappings
|
||||
*/
|
||||
// TODO: Should be forKeyPath or have a sister forKeyPath method
|
||||
- (void)registerClass:(Class<RKObjectMappable>)aClass forElementNamed:(NSString*)elementName;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -62,7 +62,7 @@ typedef enum RKRequestMethod {
|
||||
* If the object implements the RKRequestDelegate protocol,
|
||||
* it will receive request lifecycle event messages.
|
||||
*/
|
||||
@property(nonatomic, retain) id delegate;
|
||||
@property(nonatomic, assign) id delegate;
|
||||
|
||||
/**
|
||||
* The selector to invoke when the request is completed
|
||||
|
||||
@@ -913,7 +913,14 @@
|
||||
};
|
||||
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "RestKit" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 0867D691FE84028FC02AAC07 /* OTRestFramework */;
|
||||
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
|
||||
projectDirPath = "";
|
||||
|
||||
Reference in New Issue
Block a user