0
我的應用程序通過NSURL連接向我的網站發送數據(字符串),並從那裏我有一個PHP腳本,使用GET方法從iPhone發送的URL檢索數據。腳本然後搜索數據庫,如果找到匹配,它會輸出數字(日期)到iPhone檢索到的網站。刷新NSURL連接問題
我的問題是,當用戶第一次按下按鈕來「檢索」,它的工作原理。但是,如果他們改變數據並再次按下按鈕,它會從第一次檢索到與它應該檢索的新信息相反的信息。
我認爲問題可能是NSURL連接必須第二次重置,因此爲什麼它發送重複的數據,即使用戶第二次輸入新數據。有誰知道這是否是原因,如果是的話,你如何刷新連接?
在此先感謝!
下面是代碼:
-(void) retrieveData: (id) sender //Method is called indirectly when the user presses the retrieve button
{
NSString *stringToBeSent;
//sender= [sender lowercaseString];
sender= [sender stringByReplacingOccurrencesOfString:@"," withString:@"%20"];
[receivedData release];
receivedData= [[NSMutableData alloc] init];
stringToBeSent= [[NSString alloc] initWithFormat:@"http://xxx.xxx.xxx./xxx/verification.php?Numbers=%@",sender];
// NSLog(@"annie %@", stringToBeSent);
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:stringToBeSent]];
Theconn= [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];