网络请求原生

网络请求原生


NSData *paramData = [NSJSONSerialization dataWithJSONObject:dataResultM options:NSJSONWritingPrettyPrinted error:NULL];

    

    NSString *paramString = [[NSString alloc] initWithData:paramData encoding:NSUTF8StringEncoding];

    

    

    

      nslog(@"\n\n\n\n\n%@", paramString);

    

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:ssss]];

    [request setHTTPMethod:@"POST"];

    [request setHTTPBody:paramData];

    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

    

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];

    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {

        

        if (connectionError) {

            

            nslog(@"%@", connectionError.localizedDescription);

            

        } else  if ([data length] > 0) {

            

            NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

            

            nslog(@"%@", dataString);

        }

    }];

    */

猜你喜欢

转载自blog.csdn.net/heyachaodeios/article/details/51025154