0
votes

I am using an external library called 'ASIHTTPRequest' that I am using to submit a form that is on a web server through my app. Everything works great and I get the html of the response of the request. The html contains a link I get and I then do another request on that link to get the html of the second request. Heres my problem, when I try and request that link that was in the html (I have stripped it down to just the link, I am positive.) I get the same html response as the first response I got. My code will not format correctly in the page. Here is the code at http://pastie.org

http://pastie.org/3069630

2

2 Answers

1
votes

I think the problem is a misplaced if

The if (i == 1) branch should not be in the scope of the if (i == 0) code. Hope this helps

1
votes

There are a few small errors causing your problem here:

  1. Your if (i==1) { … } statement is nested inside you if (i==0) { … } statement (perhaps a mismatched closing bracket is to blame?

  2. Your if (i==1) { … }, once in the correct spot will want to be else if (i==0) { … }

Basically, the first time requestFinished: gets called and (i is 0) it starts off, adds 1 to i, makes the second request, and (still in the first response) checks to see if i is 1. i will always be 1 there so it pops up the alert view. When the second request finishes it never checks to see if i is 1 because that is nested inside the check for i being 0.

The reason you’ll want else if … is because otherwise the second if-statement will always trigger immediately after the first (because you do i++).