我有以下代码:

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


它给了我错误:

最佳答案

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

if (success)
{
    success(YES);
}

关于iphone - 块和内存释放的问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12966020/

10-14 20:53