NSURLConnection发布请求在一段时间后停止发布

时间:2015-09-09 17:17:39

标签: ios nsurlconnection nsurlrequest

我正在尝试将一些值发布到我的网络服务,该网站服务适用于Android版本,而对于iOS,它适用于大约12个请求,然后它停止发送。我做错了什么?

我每秒发送大约1个。

-(void) PostDataToServer:(NSMutableArray*) value
{
    NSString *xValue = [NSString stringWithFormat:@"%@", [value objectAtIndex:0]];
    NSString *yValue = [NSString stringWithFormat:@"%@", [value objectAtIndex:1]];
    NSString *jsonRequest = [NSString stringWithFormat:@"{\"person\":\"%@\",\"x\":\"%@\",\"y\":\"%@\",\"z\":\"%@\"}",@"1",xValue ,yValue ,@"0.0"];
    NSLog(@"Request: %@", jsonRequest);

    NSURL *url = [NSURL URLWithString:@"mywebserviceURL"];

    request = [[NSMutableURLRequest alloc] initWithURL:url];
    NSData *requestData = [NSData dataWithBytes:[jsonRequest UTF8String] length:[jsonRequest length]];

    [request setHTTPMethod:@"POST"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setValue:[NSString stringWithFormat:@"%d", [requestData length]] forHTTPHeaderField:@"Content-Length"];
    [request setHTTPBody: requestData];
    NSData *urlData= connection= [NSURLConnection connectionWithRequest:request delegate:self];
    NSLog(urlData);

0 个答案:

没有答案