简体   繁体   中英

issue with blocks and memory releases

I have the following code:

- (void) likeImage:(AHInstagramImageData *) image
            success:(void (^)(BOOL success))success
           failure:(void (^)(NSError* error, NSInteger statusCode))failure
{
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            [AHInstagramSession session].accessToken, @"access_token",
                            nil];
    NSString *likeCommentPath = [NSString stringWithFormat:@"media/%@/likes", image.imageId];
    [self postPath:likeCommentPath parameters:params success:^(AFHTTPRequestOperation *operation, id response){
        if ([operation hasAcceptableStatusCode]) {
            [[LocalyticsSession sharedLocalyticsSession] tagEvent:@"Like"];

            [[AHFacebookSession session] postAction:@"like" forImageData:image];
            [[AHTwitterSession session] postAction:@"like" andObject:image];

            success(YES);


    }failure:^(AFHTTPRequestOperation *operation, NSError *error){
         failure(error, operation.response.statusCode);
         NSLog(@"Failure on liking a photo %@", [error description]);
    }];
}

and it gives me the error:

在此处输入图片说明

Doesn't look like a memory problem. Check success block if it was actually set before you invoke it.

if (success)
{
    success(YES);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM