刷新NSURL连接问题

问题描述:

我的应用程序通过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]; 

我没有你的代码试过,但一个建议是在开始ONF的方法来设置所有的值为零。 所以下面的“nsstring * stringtibesent”将这个字符串和所有其他变量设置为零,然后您将稍后使用值设置它们。