块和内存释放问题

时间:2012-10-19 01:09:57

标签: iphone objective-c ios ipad

我有以下代码:

- (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]);
    }];
}

它给了我错误:

enter image description here

1 个答案:

答案 0 :(得分:1)

看起来不像是内存问题。检查success块是否在您调用之前实际设置了。

if (success)
{
    success(YES);
}