tags:

views:

54

answers:

1

Hi all,

I am using this code for accessing data from server,

NSString *post = [[NSString alloc] initWithFormat:@"Email=%@",GEmail];

 NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];  

 NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];  

 NSURL *url = [NSURL URLWithString:@"http://smads.in/day.php"];
 NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
 [theRequest setHTTPMethod:@"POST"];  
 [theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];  
 [theRequest setHTTPBody:postData]; 


 NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

 if( theConnection )
 {
  webData = [[NSMutableData data] retain];
 }
 else
 {

 }

it fetch data slightly late so problem is that-- i have a code which check fetched data from server--

If(flag==1)

NSlog(@"YES");

else

NSlog(@"NO");

when i click first time then it print NO when i again click then it display yes.

how i check condition in one click?

suggest me if any idea.....

Thanks,

Arun

A: 

You can do one thing.

Don't allow user to click on button until you get the response from the request.

You can use userinteraction property

Reena
but when first click is done by user then send request to server how send request without interaction.
Arun Sharma
You have not specify in your question that you are sending request on button click.Means, you want to send request on 1t click and on 2nd click you need response. m i right?
Reena
No,send request and need response in only one click
Arun Sharma
Then after clicking the button disable the user interaction and after getting the response just enable interaction....
Reena
m sorry for that u don't understand me.first u see the problem i only want when user clicks that button then after getting responce print yes on the screen where not any user interaction.
Arun Sharma
hello Reena or everyone please tell me how to solve this
Arun Sharma
Have you implement the delegate methods of NSURLConnection?
Reena
no i m not implement delegate method
Arun Sharma