Note that there are some explanatory texts on larger screens.

plurals
  1. POASIHTTPRequestTester: Asynchronous not working
    primarykey
    data
    text
    <p>I'm trying to make a App for iOS using ASIHTTPRequest, but I'm facing some issues using it. To demonstrate my problems, I've uploaded an test-project, which you can download from here: <a href="http://uploads.demaweb.dk/ASIHTTPRequestTester.zip" rel="nofollow noreferrer">http://uploads.demaweb.dk/ASIHTTPRequestTester.zip</a>.</p> <p>I've created a WebService class which use the <code>ASIHTTPRequestDelegate</code> protocol:</p> <pre><code>#import "WebService.h" #import "ASIHTTPRequest.h" @implementation WebService - (void)requestFinished:(ASIHTTPRequest *)request { NSLog(@"requestFinished"); } - (void)requestFailed:(ASIHTTPRequest *)request { NSLog(@"requestFailed"); } - (void) testSynchronous { NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; NSLog(@"starting Synchronous"); [request startSynchronous]; NSError *error = [request error]; if (!error) { NSLog(@"got response"); } } - (void) testAsynchronous { NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; NSLog(@"starting Asynchronous"); [request startAsynchronous]; } @end </code></pre> <p>The synchronous method is working fine, but the asynchronous is not working at all. First the requestFinished and requestFailed was never called and right now I'm getting an EXC_BAD_ACCESS. The two test-methods is called from my ViewController's <code>viewDidLoad</code>. I hope someone can help me making this work.</p> <p><strong>EDIT1:</strong> As per <a href="https://stackoverflow.com/questions/2164948">this topic</a>, it is possible because of the <code>Automatic Reference Counting</code> which is enabled for my project. The topic advice to add a <code>[self retain]</code>, but I cannot do this with ARC turned on. Anyone with a solution for this?</p> <p><strong>EDIT2:</strong> Update as per answer from <a href="https://stackoverflow.com/a/8369939/617413">MrMage</a>.</p> <pre><code>@interface ViewController() @property (nonatomic,strong) WebService *ws; @end @implementation ViewController @synthesize ws = _ws; #pragma mark - View lifecycle - (void)viewDidLoad { [super viewDidLoad]; [self setWs:[[WebService alloc] init]]; [self.ws testSynchronous]; [self.ws testAsynchronous]; } @end </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload