Ios 服务器中的POST方法接收重复

Ios 服务器中的POST方法接收重复,ios,post,request,Ios,Post,Request,我正在向服务器发送一个POST请求,但他们收到了相同日期甚至时间的重复请求。这是我的代码: -(void) getTerms{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ User *mUser = [[User alloc]init]; NSString *appFile1 = [self getUserFile]; m

我正在向服务器发送一个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

            }

        });

    });

}

我只是想知道我的代码怎么了?提前感谢

我就是这样解决问题的:

-(void) getCredit{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        NSString *post = [NSString stringWithFormat:@"Method=%@",mMethod];
        NSMutableURLRequest *request = [ServerName postToServer:post];

        dispatch_async(dispatch_get_main_queue(), ^{                
            NSURLResponse *requestResponse;
            NSData *requestHandler = [NSURLConnection sendSynchronousRequest:request returningResponse:&requestResponse error:nil];

            NSString *jsonString = [[NSString alloc] initWithBytes:[requestHandler bytes] length:[requestHandler length] encoding:NSUTF8StringEncoding];

            NSDictionary *res = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil];
            NSDictionary *res1 = [res objectForKey:@"ServerResponse"];
        });  
    });
}

该方法是如何执行的?通过呼叫或按钮??您使用的是哪个ios版本?我在使用8.1@LenaBru时遇到了同样的问题,但我解决了。让我发布我的代码作为答案:)