Search code examples
objective-cxcode4.2asihttprequest

error in ASIHttpRequest


Now I'm involved in a project which needs to download a huge amount of images from server. Following the recommendation online, I tried the ASIHttpRequest. But when I copied all the necessary classes into my project, I got 30+ errors in those classes. Most of the errors are about using retain, release or autorelease. Because I'm using Xcode 4.2.1, explicit retain, release and autorelease is forbidden. But some other errors are quite ridiculous.

for example, in class ASIDataCompressor.m, following method should return NSData

- (NSData *)compressBytes:(Bytef *)bytes length:(NSUInteger)length error:(NSError **)err shouldFinish:(BOOL)shouldFinish

but I see one portion of the method return NO

if (status == Z_STREAM_END) {
        break;
    } else if (status != Z_OK) {
        if (err) {
            *err = [[self class] deflateErrorWithCode:status];
        }
        return NO;
    }

Some other classes also have similar problems.

My questions are:

  1. Did I download the wrong package?

  2. How to let compiler ignore those explicit retain, release and autorelease?


Solution

  • "Xcode 4.2.1, explicit retain, release and autorelease is forbidden" because you have ARC enabled when you created your project. Disable ARC.

    ASIDataCompressor.m method looks fine here. Don't know how you got it wrong.

    Since you just picked up ASIHTTP in your project I would recommend switching to AFNetworking because read this: [request release]