1
我發送一個POST請求到服務器,但他們收到它重複相同的日期,甚至時間。這是我的代碼:POST方法接收服務器中重複
-(void) getTerms{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
User *mUser = [[User alloc]init];
NSString *appFile1 = [self getUserFile];
mUser = [NSKeyedUnarchiver unarchiveObjectWithFile:appFile1];
NSString *post = [NSString stringWithFormat:@"Method=GetFAQ&CustomerID=%@",mUser.customerID];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[post length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:[ServerName serverName]]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPBody:postData];
NSURLConnection *theConnection = [NSURLConnection connectionWithRequest:request delegate:self];
dispatch_async(dispatch_get_main_queue(), ^{
[SVProgressHUD dismiss];
if(theConnection){
// other codes
}
});
});
}
我只是想知道我的代碼有什麼問題?在此先感謝
如何被執行的方法是什麼?從通話或按鈕? – 2014-11-02 12:38:04
您使用的是哪個ios版本?我有同樣的問題 – 2014-11-24 10:29:18
即時通訊使用8.1 @LenaBru但我解決了它。讓我發表我的代碼作爲答案:) – Rudi 2014-11-27 15:59:34