DELETE 請求參數保存在Body 中


NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
 
    NSString * url = [NSString stringWithFormat:signatureProxy,model2.scheduleId];
    NSMutableURLRequest * req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]];
    req.HTTPMethod = @"DELETE";
    req.HTTPBody = [NSJSONSerialization dataWithJSONObject:parameter options:NSJSONWritingPrettyPrinted error:nil];//[parameter JSONData];//dic字典相當於parameters,請求體里的東西
    req.allHTTPHeaderFields = @{
                                @"Content-Type":@"application/json"
                                };//請求頭里的東西
    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    [NSURLConnection sendAsynchronousRequest:req queue:queue completionHandler:^(NSURLResponse * _Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {
        if (connectionError) {
            //失敗
            [ToolOfClass showMessage:@"操作失敗"];
        } else {
            //成功
            dispatch_async(dispatch_get_main_queue(), ^{
                //回調或者說是通知主線程刷新,
                [_tableView reloadData];
                [ToolOfClass showMessage:@"操作成功"];
           });
        }
    }];


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM