alamofire

Trying to access error code in Alamofire

给你一囗甜甜゛ 提交于 2020-04-14 07:46:30
问题 I am using an Alamofire 4. When I do print(response.debugDescription) I have something like this in the console: [Request]: https://api2.website.com [Response]: nil [Data]: 0 bytes [Result]: FAILURE: Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x17444ace0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={NSErrorPeerAddressKey=<CFData 0x170490e50 [0x1ab165bb8]>{length = 16, capacity = 16, bytes =

Swift3 Alamofire SwiftyJSON 练习

浪尽此生 提交于 2020-04-10 22:15:34
转自我的github: https://github.com/uniquejava/AlamofireSwiftyJSONDemo Alamofire | SwiftyJSON Demo My swift3 exercise for this excellent tutorial with some of my own changes. Setup CocoaPods ➜ sudo gem update --system ➜ sudo gem install cocoapods ➜ pod setup ➜ (Xcode8 create single view application) ➜ cd AlamofireSwiftyJSONDemo ➜ pod init ➜ open -a Xcode Podfile ➜ Make some changes here, see below ➜ pod install Analyzing dependencies Downloading dependencies Installing Alamofire (4.0.1) Installing SwiftyJSON (3.1.1) Generating Pods project Integrating client project [!] Please close any current

iOS create generic Alamofire request using swift

情到浓时终转凉″ 提交于 2020-03-19 09:22:57
问题 Recently I have started learning iOS app development using swift so I am new to it. I want to implement rest api call in swift & found that we can achieve this using URLRequest . So I have written generic method to call all type(like get, put, post ) of rest api as below. import Foundation //import Alamofire public typealias JSON = [String: Any] public typealias HTTPHeaders = [String: String]; public enum RequestMethod: String { case get = "GET" case post = "POST" case put = "PUT" case delete

iOS Swift uploading PDF file with Alamofire (Multipart)

ε祈祈猫儿з 提交于 2020-03-13 04:24:49
问题 I'm currently developing an application using iOS 10 and Swift 3 and Alamofire 4 The purpose of this application is to upload a PDF file generated previously. The PDF generation is working perfectly and the file is created. However the upload doesn’t work…
 I received a success response but the file is not uploaded. My server response Multi part Content-Type => multipart/form-data; boundary=alamofire.boundary.56958be35bdb49cb Multi part Content-Length => 293107 Multi part Content-Boundary =>

iOS Swift uploading PDF file with Alamofire (Multipart)

只谈情不闲聊 提交于 2020-03-13 04:21:10
问题 I'm currently developing an application using iOS 10 and Swift 3 and Alamofire 4 The purpose of this application is to upload a PDF file generated previously. The PDF generation is working perfectly and the file is created. However the upload doesn’t work…
 I received a success response but the file is not uploaded. My server response Multi part Content-Type => multipart/form-data; boundary=alamofire.boundary.56958be35bdb49cb Multi part Content-Length => 293107 Multi part Content-Boundary =>

Multiple encoding types for Alamofire Request

强颜欢笑 提交于 2020-02-21 10:40:50
问题 I need to make a POST request with an HTTP Body with a JSON object, but I also need to use url query parameters in the same request. POST: http://www.example.com/api/create?param1=value&param2=value HTTP Body: { foo : [ bar, foo], bar: foo} Is this supported by Alamofire? How would I go about doing this? 回答1: This is definitely a valid use case. I've ran into similar issues with trying to append access tokens as query parameters to a POST request. Here's a function that should make things a

Multiple encoding types for Alamofire Request

≡放荡痞女 提交于 2020-02-21 10:39:12
问题 I need to make a POST request with an HTTP Body with a JSON object, but I also need to use url query parameters in the same request. POST: http://www.example.com/api/create?param1=value&param2=value HTTP Body: { foo : [ bar, foo], bar: foo} Is this supported by Alamofire? How would I go about doing this? 回答1: This is definitely a valid use case. I've ran into similar issues with trying to append access tokens as query parameters to a POST request. Here's a function that should make things a

Multiple encoding types for Alamofire Request

牧云@^-^@ 提交于 2020-02-21 10:39:05
问题 I need to make a POST request with an HTTP Body with a JSON object, but I also need to use url query parameters in the same request. POST: http://www.example.com/api/create?param1=value&param2=value HTTP Body: { foo : [ bar, foo], bar: foo} Is this supported by Alamofire? How would I go about doing this? 回答1: This is definitely a valid use case. I've ran into similar issues with trying to append access tokens as query parameters to a POST request. Here's a function that should make things a

Alamofire网络库基础教程

怎甘沉沦 提交于 2020-02-21 06:31:42
原文 Beginning Alamofire Tutorial 原文作者 Essan Parto 译者 星夜暮晨 (QQ:412027805) http://www.jianshu.com/p/f1208b5e42d9 CocoaChina 对应地址: http://www.cocoachina.com/ios/20141202/10390.html 2014年12月1日 2015年4月15日,更新至Xcode6.3及Swift1.2 感谢 nevermosby 对本文的遗漏之处进行指正,同时也感谢 SwiftLanguage 的推荐 学习如何使用 Alamofire 来轻松地实现 Swift 的网络请求处理 AFNetworking 是 iOS 和 OS X 上最受欢迎的第三方库之一。它曾在我们的2012年的读者评选中荣获 2012年度最佳 iOS 库 称号。它同样也在 Github 上面获得了14000多个 stars 和4000多个 forks,是使用最广的开源项目之一。 最近,AFNetworking 的作者 Mattt Thompson 提交了一个新的类似于 AFNetworking 的网络 基础库,并且是专门使用最新的 Swift 语言来编写的,名为: Alamofire 。 AFNetwork 的前缀 AF 是 Alamofire 的缩写,因此这个新的库名称其实是根据

swift网络数据请求方法

北慕城南 提交于 2020-02-21 05:46:54
搭建一个apache服务器,用php编写一个返回给客户端请求数据的脚本 1 <?php 2 // header("Content-type:text/html;charset=utf-8"); 3 header("Content-type:text/json;charset=utf-8"); 4 if (isset($_REQUEST['name'])) { 5 $result = $_REQUEST['name']; 6 $arr=array("result"=>$result); 7 $json=json_encode($arr); 8 echo $json; 9 } 10 ?> 该php实现了接收一个客户端的远程post或者get请求,然后返回给其一个简单的json字串, 打开Xcode创建一个singleView工程,在IB中添加一个button和一个label并连线到代码中的outlet,我的测试php文件的地址为: let url = "http://192.168.1.106/apprequesttest/index.php" 下面开始描述两种实现网络请求的方法,在button的action事件中添加网络请求 IOS SDK自带的网络请求方法: GET请求方法: 1 var msg = "jimmy" 2 NSURLConnection