Guest User

Untitled

a guest
Aug 21st, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. Potential leak on a retain
  2. - (void)generateTokenWithUserId: (NSString *)uniqueId {
  3.  
  4. NSLog(@"TokenGenerator - generateTokenWithUserId: '%@'", uniqueId);
  5.  
  6. NSString *myMD5String = [Utilities returnMD5Hash:uniqueId];
  7.  
  8. // Create the request.
  9. NSMutableString *authURL = [[NSMutableString alloc] initWithString:CLOUDMADE_AUTH];
  10. [authURL appendString: localApiKey];
  11. [authURL appendString: USER_ID];
  12. [authURL appendString: myMD5String];
  13.  
  14. NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:authURL]
  15. cachePolicy: NSURLRequestUseProtocolCachePolicy
  16. timeoutInterval: 60.0];
  17. [theRequest setHTTPMethod: @"POST"];
  18.  
  19. NSLog(@"TokenGenerator URL - '%@'", authURL);
  20.  
  21. // create the connection with the request
  22. // and start loading the data
  23. //NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
  24. NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
  25.  
  26. if (connection) {
  27. // Create the NSMutableData to hold the received data.
  28. // receivedData is an instance variable declared elsewhere.
  29. responseData = [[NSMutableData data] retain];
  30. } else {
  31. // Inform the user that the connection failed.
  32. }
  33.  
  34. [authURL release];
  35. }
  36.  
  37. - (void) dealloc {
  38.  
  39. NSLog(@"TokenGenerator - dealloc");
  40.  
  41. [responseData release];
  42. [localApiKey release];
  43.  
  44. [super dealloc];
  45. }
  46.  
  47. @class TokenGenerator;
  48.  
  49. @protocol TokenGeneratorDelegate <NSObject>
  50.  
  51. - (void)tokenGeneratorDidFinishGeneration:(TokenGenerator *)tokenGenerator token:(NSString *)tokenGenerated;
  52.  
  53. @end
  54.  
  55.  
  56. @interface TokenGenerator : NSObject {
  57.  
  58. NSString *localApiKey;
  59. id<TokenGeneratorDelegate> delegate;
  60. NSMutableData *responseData;
  61. }
  62.  
  63. @property (nonatomic, assign) id<TokenGeneratorDelegate>delegate;
  64.  
  65. - (id) initWithApikey:(NSString*) apiKey delegate:(id)anObject;
  66. - (void)generateTokenWithUserId: (NSString *)uniqueId;
  67.  
  68. @end
  69.  
  70. NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
Add Comment
Please, Sign In to add comment