2010-08-04 33 views
0

我使用从服务器访问数据的代码访问来自服务器的数据,通过PHP在iphone

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 
{ 

} 

它获取数据,尾盘小幅所以问题是that-- 我有检查从获取数据的代码服务器 -

If(flag==1) 

NSlog(@"YES"); 

else 

NSlog(@"NO"); 

当我第一次点击时,然后打印没有当我再次点击,然后显示是。

如何检查一次点击条件?

建议我,如果任何想法.....

感谢,

阿伦

回答

0

你可以做一两件事。

不要让用户点击按钮,直到获得请求的响应。

你可以使用userinteraction属性

+0

但是当第一次点击完成由用户然后发送请求到服务器如何发送请求没有交互。 – 2010-08-04 06:50:09

+0

您还没有在您的问题中指定您通过单击按钮发送请求。 意思是,你想发送请求1t点击和第二次点击你需要回应。我对吗? – Reena 2010-08-04 07:01:03

+0

不,只需点击一次发送请求和需要响应 – 2010-08-04 07:02:52