0
votes

As a beginner of iOS developer. I use ARC in my project. And I even use ASIHttpRequest to make some work easier. As you know, ASIHttpRequest not support ARC. I've added the -fno-objc-arc compiler flag to make it work. Now, here is my question. How can I release the 'request' object if some of my code like this :

NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
   __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setCompletionBlock:^{
      NSData *responseData = [request responseData];
   }];
   [request setFailedBlock:^{
      NSError *error = [request error];
   }];
   [request startAsynchronous];
2
Using ARC means you don't worry about releasing it.James Black
And, there is no 'alloc', so even under a non-ARC environment there is no need to release...SEG

2 Answers

1
votes

Its my understanding that the compiler does the right thing with NSObjects when mixing ARC and non-ARC code.

Based on the naming conventions for Cocoa methods, responseData should be a non-owning reference. Thus, you should not be responsible for retaining/releasing it. The request object owns it.

0
votes

There is no need to release this 'request' since these code is in the file using ARC. The compiler will help you to insert release method. However for objects in ASIHTTPRequest.m file, you need to release them (actually you do not need to do that) since you have added the -fno-objc-arc compiler flag, and complier will not insert release method for you.