Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Memory Leak Fixes
  • Loading branch information
kylebrowning committed Sep 28, 2012
1 parent e154dd4 commit e17f5f0
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 10 deletions.
1 change: 1 addition & 0 deletions DIOSComment.m
Expand Up @@ -94,6 +94,7 @@ + (void)commentIndexWithPage:(NSString *)page
[commentIndexDict setValue:parameteres forKey:@"parameters"];
[commentIndexDict setValue:pageSize forKey:@"pagesize"];
[self commentIndex:commentIndexDict success:success failure:failure];
[commentIndexDict release];
}

+ (void)commentIndex:(NSDictionary *)params
Expand Down
2 changes: 1 addition & 1 deletion DIOSFile.h
Expand Up @@ -40,7 +40,7 @@
+ (void) fileGet:(NSDictionary *)params
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ (void) fileSave:(NSDictionary *)params
+ (void)fileSave:(NSDictionary *)file
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure;
+ (UIImageView *) getImageViewForFileImage:(NSDictionary *) file;
Expand Down
1 change: 1 addition & 0 deletions DIOSFile.m
Expand Up @@ -63,6 +63,7 @@ + (UIImageView *) getImageViewForFileImage:(NSDictionary *) file; {
NSURL *url = [NSURL URLWithString:[file objectForKey:@"uri_full"]];
UIImageView *remoteImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[remoteImage setImageWithURL:url];
[remoteImage release];
return remoteImage;
}
@end
12 changes: 6 additions & 6 deletions DIOSNode.m
Expand Up @@ -76,8 +76,7 @@ + (void)nodeUpdate:(NSDictionary *)node
+ (void)nodeDelete:(NSDictionary *)node
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error)) failure {

[[DIOSSession sharedSession] deletePath:[NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, kDiosBaseNode, [node objectForKey:@"nid"]]
[[DIOSSession sharedSession] deletePath:[NSString stringWithFormat:@"%@/%@/%@", kDiosEndpoint, kDiosBaseNode, [node objectForKey:@"nid"]]
parameters:node
success:success
failure:failure];
Expand All @@ -93,6 +92,7 @@ + (void)nodeIndexWithPage:(NSString *)page fields:(NSString *)fields parameters:
[nodeIndexDict setValue:parameteres forKey:@"parameters"];
[nodeIndexDict setValue:pageSize forKey:@"pagesize"];
[self nodeIndex:nodeIndexDict success:success failure:failure];
[nodeIndexDict release];
}

+ (void)nodeIndex:(NSDictionary *)params
Expand All @@ -111,11 +111,11 @@ + (void)nodeAttachFile:(NSDictionary *)params
}];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setUploadProgressBlock:^(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
NSLog(@"Sent %lld of %lld bytes", totalBytesWritten, totalBytesExpectedToWrite);
}];

// [operation setUploadProgressBlock:^(NSInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite) {
// NSLog(@"Sent %qi of %qi bytes", totalBytesWritten, totalBytesExpectedToWrite);
// }];
[operation setCompletionBlockWithSuccess:success failure:failure];
[operation start];
[operation release];
}
@end
5 changes: 4 additions & 1 deletion DIOSSession.h
Expand Up @@ -41,9 +41,12 @@

@interface DIOSSession : AFHTTPClient {
NSDictionary *user;
NSMutableDictionary *accessTokens;
}
@property (strong, nonatomic) NSDictionary *user;
@property (nonatomic, retain) NSMutableDictionary *accessTokens;
+ (DIOSSession *)sharedSession;

+ (DIOSSession *)sharedSessionWithURL:(NSString*)url;
- (void) addHeaderValue:(NSString*)value forKey:(NSString*)key;
@end

17 changes: 15 additions & 2 deletions DIOSSession.m
Expand Up @@ -40,16 +40,26 @@
#import "AFPropertyListRequestOperation.h"

@implementation DIOSSession
@synthesize user;
@synthesize user, accessTokens;
+ (DIOSSession *)sharedSession {
static dispatch_once_t once;
static DIOSSession *sharedSession;
dispatch_once(&once, ^ {
dispatch_once(&once, ^ {
sharedSession = [[self alloc] initWithBaseURL:[NSURL URLWithString:kDiosBaseUrl]];
[sharedSession setParameterEncoding:AFJSONParameterEncoding];
});
return sharedSession;
}
+ (DIOSSession *)sharedSessionWithURL:(NSString*)url {
static dispatch_once_t once;
static DIOSSession *sharedSession;
dispatch_once(&once, ^ {
sharedSession = [[self alloc] initWithBaseURL:[NSURL URLWithString:url]];
[sharedSession setParameterEncoding:AFJSONParameterEncoding];
});
[sharedSession setBaseURL:[NSURL URLWithString:url]];
return sharedSession;
}

- (id)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url];
Expand All @@ -64,4 +74,7 @@ - (id)initWithBaseURL:(NSURL *)url {

return self;
}
- (void) addHeaderValue:(NSString*)value forKey:(NSString*)key {
[self setDefaultHeader:key value:value];
}
@end
2 changes: 2 additions & 0 deletions DIOSTaxonomy.m
Expand Up @@ -50,6 +50,7 @@ + (void)getTreeWithVid:(NSString *)vid
[params setValue:parent forKey:@"parent"];
[params setValue:maxDepth forKey:@"max_depth"];
[self getTreeWithParams:params success:success failure:failure];
[params release];
}
+ (void)getTreeWithParams:(NSDictionary *)params
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
Expand All @@ -73,6 +74,7 @@ + (void)selectNodesWithTid:(NSString *)tid
[params setValue:pager forKey:@"pager"];
[params setValue:order forKey:@"prder"];
[self selectNodesWithParams:params success:success failure:failure];
[params release];
}
+ (void)selectNodesWithParams:(NSDictionary *)params
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject)) success
Expand Down
1 change: 1 addition & 0 deletions DIOSUser.m
Expand Up @@ -111,6 +111,7 @@ + (void)userIndexWithPage:(NSString *)page
[userIndexDict setValue:parameteres forKey:@"parameters"];
[userIndexDict setValue:pageSize forKey:@"pagesize"];
[self userIndex:userIndexDict success:success failure:failure];
[userIndexDict release];
}

+ (void)userIndex:(NSDictionary *)params
Expand Down

0 comments on commit e17f5f0

Please sign in to comment.