2010-08-04 34 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