Why does this code generates a leak? How could it be solved?

This is the original call:

```
NSString * url = @"https://theserverurl/user/login" ;
NSDictionary *parameters = @{@"login":@"the-email@mail.com", @"password":@"encrypted-password"} ;

[[BackEndAPI sharedManager] NSURLSessionOperation: @"POST" url: url parameters: parameters success:^(NSURLRequest *request, NSHTTPURLResponse * response, id responseObject) {
   // Success
} failure:^(IDLEngineError *engineError) {
   // Failure        
}] ;

```

This is the singleton which handles the NSURL request:

```
- (NSMutableURLRequest *) NSURLSessionOperation:(NSString *) restOperation
                                             url:(NSString *)url
                                      parameters:(id)parameters
                                         success:(void (^)(NSMutableURLRequest *request, NSHTTPURLResponse * response, id responseObject))success
                                         failure:(void (^)(IDLEngineError *))failure {

    NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];

    __weak id weakSelf = self ;

    // POST
    if ([restOperation isEqualToString:@"POST"]) {

        NSError *error;
        NSURLSession *session = [NSURLSession sessionWithConfiguration: sessionConfig ];

        // Create the request
        __block NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: url ] ];
        [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"] ;
        request.HTTPMethod = @"POST";
        NSData *postData = [NSJSONSerialization dataWithJSONObject: parameters options: 0 error:&error];
        [request setHTTPBody:postData];

        // Perform operation
        NSURLSessionDataTask * task = [session dataTaskWithRequest: request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {

            // This generates a leak!!!!
            success(request, nil, nil) ;

        }] ;

        [task resume] ;

    }

    return nil ;

}

```

Please take a look to the leaked app on GitHub:

<https://github.com/arkyxperience/myleakedapp>

Find also here the report (screenshot) coming from Instruments:

[![Result of Instruments - Leaks](https://i.stack.imgur.com/AmxhD.png)](https://i.stack.imgur.com/AmxhD.png)