1 Replies - 4921 Views - Last Post: 28 June 2011 - 08:06 AM

#1 Alhazred  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 181
  • Joined: 25-July 07

Compare a string returned by a webapplication

Posted 28 June 2011 - 07:29 AM

I'm just learning to develo applications for iPhone and I'm now following a tutorial.
It makes me send a request to a php script on a website and after that it writes in the console the string returned from the script.

I want to change a bit the app.
I want to write inside the console a text depending on the answer received from the php script.

By now I use this code to write inside the console
NSURLResponse* response;
NSError* error;
NSData* risultato = [NSURLConnection sendSynchronousRequest:richiesta returningResponse:&response error:&error];
	
NSLog(@"%@", [[[NSString alloc] initWithData:risultato encoding:NSASCIIStringEncoding] autorelease]);


The script returns "ok" or "ko", and I read it correctly inside the console.

I need to add something like
if("the response received from the script" is equal to "ok"){
   //text for ok
}
else {
   //text for ko
}


My problem is what to write for the "if" condition.
How can I make that comparison?

Is This A Good Question/Topic? 0
  • +

Replies To: Compare a string returned by a webapplication

#2 Alhazred  Icon User is offline

  • D.I.C Head

Reputation: 9
  • View blog
  • Posts: 181
  • Joined: 25-July 07

Re: Compare a string returned by a webapplication

Posted 28 June 2011 - 08:06 AM

I had the answer in front of my eyes and I didn't see it...
if ([[[[NSString alloc] initWithData:risultato encoding:NSASCIIStringEncoding] autorelease] isEqualToString:@"ok"]) {


This post has been edited by Alhazred: 28 June 2011 - 08:06 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1