Skip to content

Commit

Permalink
ios sdk: memory management for delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
Yujuan Bao committed Aug 11, 2010
1 parent bceafdc commit a98bcb4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/FBDialog.m
Expand Up @@ -349,7 +349,6 @@ - (id)init {
- (void)dealloc {
_webView.delegate = nil;
[_webView release];
[_delegate release];
[_params release];
[_serverURL release];
[_spinner release];
Expand Down Expand Up @@ -514,7 +513,7 @@ - (id)initWithURL: (NSString *) serverURL
self = [self init];
_serverURL = [serverURL retain];
_params = [params retain];
_delegate = [delegate retain];
_delegate = delegate;

return self;
}
Expand Down
10 changes: 1 addition & 9 deletions src/FBLoginDialog.m
Expand Up @@ -34,7 +34,7 @@ - (id)initWithURL:(NSString*) loginURL
self = [super init];
_serverURL = [loginURL retain];
_params = [params retain];
_loginDelegate = [delegate retain];
_loginDelegate = delegate;
return self;
}

Expand Down Expand Up @@ -87,13 +87,5 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[_loginDelegate fbDialogNotLogin];
}
}

/**
* Override FBDialog : free the space
*/
- (void)dealloc {
[_loginDelegate release];
[super dealloc];
}

@end
4 changes: 2 additions & 2 deletions src/FBRequest.h
Expand Up @@ -37,12 +37,12 @@
/**
* The URL which will be contacted to execute the request.
*/
@property(nonatomic,assign) NSString* url;
@property(nonatomic,copy) NSString* url;

/**
* The API method which will be called.
*/
@property(nonatomic,assign) NSString* httpMethod;
@property(nonatomic,copy) NSString* httpMethod;

/**
* The dictionary of parameters to pass to the method.
Expand Down
2 changes: 1 addition & 1 deletion src/FBRequest.m
Expand Up @@ -45,7 +45,7 @@ + (FBRequest *)getRequestWithParams:(NSMutableDictionary *) params
delegate:(id<FBRequestDelegate>) delegate
requestURL:(NSString *) url {
FBRequest* request = [[[FBRequest alloc] init] autorelease];
request.delegate = [delegate retain];
request.delegate = delegate;
request.url = [url retain];
request.httpMethod = [httpMethod retain];
request.params = [params retain];
Expand Down
6 changes: 3 additions & 3 deletions src/Facebook.h
Expand Up @@ -35,11 +35,11 @@

}

@property(nonatomic, retain) NSString* accessToken;
@property(nonatomic, copy) NSString* accessToken;

@property(nonatomic, retain) NSDate* expirationDate;
@property(nonatomic, copy) NSDate* expirationDate;

@property(nonatomic, retain) id<FBSessionDelegate> sessionDelegate;
@property(nonatomic, assign) id<FBSessionDelegate> sessionDelegate;


- (void) authorize:(NSString*) application_id
Expand Down
13 changes: 2 additions & 11 deletions src/Facebook.m
Expand Up @@ -125,11 +125,7 @@ - (void) authorize:(NSString*)application_id
[params setValue:scope forKey:@"scope"];
}

if (_sessionDelegate) {
[_sessionDelegate release];
_sessionDelegate = nil;
}
_sessionDelegate = [delegate retain];
_sessionDelegate = delegate;

[_loginDialog release];
_loginDialog = [[FBLoginDialog alloc] initWithURL:kOAuthURL
Expand All @@ -151,11 +147,7 @@ - (void) authorize:(NSString*)application_id
*/
- (void)logout:(id<FBSessionDelegate>)delegate {

if (_sessionDelegate) {
[_sessionDelegate release];
_sessionDelegate = nil;
}
_sessionDelegate = [delegate retain];
_sessionDelegate = delegate;

NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
[self requestWithMethodName:@"auth.expireSession"
Expand Down Expand Up @@ -443,7 +435,6 @@ - (void)request:(FBRequest*)request didFailWithError:(NSError*)error{
- (void)dealloc {
[_accessToken release];
[_expirationDate release];
[_sessionDelegate release];
[_request release];
[_loginDialog release];
[_fbDialog release];
Expand Down

0 comments on commit a98bcb4

Please sign in to comment.