简体   繁体   English

块和内存释放的问题

[英]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. 在调用success块之前,请检查是否success设置了该块。

if (success)
{
    success(YES);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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