DTWebService 1.0

DTWebService 1.0

测试已测试
语言语言 Obj-CObjective C
许可 自定义
发布最新版本2015年6月

Dimitris - Sotiris Tsolis 维护。



  • Dimitris - Sotiris Tsolis

这是一个使 HttpRequests 和 NSURLRequest 类别支持自定义头和文件的分装器。除了其他功能外,该网络服务还具有忽略无效 SSL 证书(通过设置受信任的主机)的能力。它还使用块来跟踪请求的成功响应数据、失败或请求的进度百分比。

安装

  • 过时的复制粘贴 DTWebService 文件夹到您的项目中的方法
  • 使用 CocoaPods。将 pod 'DTWebService' 添加到 Podfile。

示例用法

示例 1:发送简单请求(将 sendAsyncRequest: 改为 sendTrustedRequest: 将忽略任何无效的 SSL 证书)

[DTWebService sendAsyncRequest:request finishedBlock:^(NSData *data, NSStringEncoding stringEncoding) {
    // handle completion
} fail:^(NSError *error, BOOL cancelled) {
    // handle failure
} progress:^(float progressPercentage) {
    // handle progress (update ui etc.)
}];

示例 2:发送可取消的请求

DTWebService *webService = [[DTWebService alloc] initWithURL:[NSURL URLWithString:@"a url..."]];
[webService startWithFinishedBlock:^(NSData *data, NSStringEncoding stringEncoding) {
    
} fail:^(NSError *error, BOOL cancelled) {
    
} progress:^(float progressPercentage) {
    
}];

....

[webService stop]; // stop/cancel the request