{"id":2902,"date":"2017-06-21T13:36:07","date_gmt":"2017-06-21T08:06:07","guid":{"rendered":"https:\/\/www.innovationm.com\/blog\/?p=2902"},"modified":"2017-06-21T13:36:07","modified_gmt":"2017-06-21T08:06:07","slug":"alamofire","status":"publish","type":"post","link":"https:\/\/www.innovationm.com\/blog\/alamofire\/","title":{"rendered":"Alamofire"},"content":{"rendered":"<h2><strong>Alamofire:<\/strong><\/h2>\n<p>Alamofire is a HTTP networking based library for iOS and macOS. It is used to handle HTTP request and response. It is the wrapper class of URLSession.<\/p>\n<h3><strong>Before Alamofire:<\/strong><\/h3>\n<ol>\n<li>You need to prepare all request by yourself<\/li>\n<li>Task handling is complicated<\/li>\n<li>Multipart request and File downloading &amp;\u00a0uploading is complicated<\/li>\n<li>Image caching needs to done by yourself<\/li>\n<\/ol>\n<h3><strong>Uses of Alamofire:<\/strong><\/h3>\n<ol>\n<li>It&#8217;s incredibly easy to use and makes everything look a lot cleaner<\/li>\n<li>Task handling is easy.<\/li>\n<li>You can access data on the Internet with very little effort<\/li>\n<li>Upload files or data with multipart, stream easily.<\/li>\n<li>Download a file or resume a download already in progress.<\/li>\n<li>You can use AlamofireImage to download and cache images<\/li>\n<\/ol>\n<h2><strong>Work with Alamofire:<\/strong><\/h2>\n<p>Alamofire library provides you an easy way to handle all network related task. It reduces the efforts of developer because developer need not to directly deal with`<strong>\u00a0URLSession<\/strong> `. Alamofire uses `<strong>\u00a0URLSession<\/strong> ` internally. Alamofire calls for a similar approach in that, one creates a <em class=\"markup--em markup--p-em\">router<\/em> by conforming to a protocol, URLRequestConvertible. Under the hood, Alamofire calls for a singleton pattern that\u2019s built on top of an URLSessionConfiguration. Everything with Alamofire is\u00a0asynchronous.<\/p>\n<h3><strong>1. Data\u00a0Request with and without Alamofire:<\/strong><\/h3>\n<p>Here is the code to send request with `<strong>\u00a0URLSession<\/strong> `:<\/p>\n<pre class=\"lang:swift decode:true\">\/\/ Create object of URLSessionConfiguration\r\nlet sessionConfig = URLSessionConfiguration.default\r\nsessionConfig.timeoutIntervalForRequest = 40\r\n\r\n\/\/ Create object of URLSession\r\nlet session = URLSession(configuration: sessionConfig)\r\n\r\n\/\/ Prepare request\r\nlet url = URL(string: \"www.example.com\")\r\nvar request = URLRequest(url: url!)\r\nlet newDict = [\"Your key\": \"Your value\"]\r\nrequest.httpMethod = \"POST\"\r\ndo {\r\n\r\n    \/\/ Convert request to json\r\n    let jsonData = try JSONSerialization.data(withJSONObject: newDict, options: [])\r\n    request.httpBody = jsonData\r\n    request.addValue(\"application\/json\", forHTTPHeaderField: \"Content-Type\")\r\n    request.addValue(\"application\/json\", forHTTPHeaderField: \"Accept\")\r\n\r\n    \/\/ Prepare task\r\n    let task = session.dataTask(with: request, completionHandler: {\r\n        responseData, response, error -&gt; Void in\r\n\r\n        \/\/ Handle response\r\n        print(response!)\r\n        do {\r\n            if responseData != nil {\r\n                let json = try JSONSerialization.jsonObject(with: responseData!, options: .mutableLeaves)\r\n                \/\/ Use response json\r\n            } else {\r\n                \/\/ Handle null data here\r\n            }\r\n        } catch {\r\n            \/\/ Handle your exception here\r\n        }\r\n    })\r\n\r\n    \/\/ Send request\r\n    task.resume()\r\n} catch {\r\n    \/\/ Handle your exception here\r\n}<\/pre>\n<ol>\n<li>Create an object of `<strong>URLSessionConfiguration<\/strong>` for session Configuration.<\/li>\n<li>Create object of session class using ` <strong>URLSessionConfiguration<\/strong> ` object.<\/li>\n<li>Prepare\u00a0URLRequest object using your url and set request type in `<strong> httpMethod<\/strong> `.<\/li>\n<li>Convert Dictionary to JSON using ` <strong>JSONSerialization.data()\u00a0<\/strong>` and add it in request body and add other parameters for request header.<\/li>\n<li>Make an object of task using ` <strong>session.dataTask(with: request, comletionHandler: nil)<\/strong> `<\/li>\n<li>Now resume the task to start execution.<\/li>\n<li>In completion handler, you receive the response. Do whatever you want to do with this data \ud83d\ude42<\/li>\n<\/ol>\n<p>If you\u00a0use alamofire then you\u00a0need not to do all the steps. You\u00a0just need to follow few of them.<\/p>\n<pre class=\"lang:swift decode:true\">\/\/ Create object of URLSessionConfiguration\r\nlet sessionConfig = URLSessionConfiguration.default\r\nsessionConfig.timeoutIntervalForResource = 40 \/\/ seconds\r\n\r\n\/\/ Create object of SessionManager\r\nlet manager = Alamofire.SessionManager(configuration: sessionConfig)\r\nlet url = URL(string: \"www.example.com\")\r\n\r\n\/\/ Send Request\r\nmanager.request(url!, method: HTTPMethod.post, parameters: [\"your key\": \"value\"], encoding: JSONEncoding.default, headers: nil).responseData(completionHandler: { response -&gt; Void in\r\n\r\n    \/\/ Handle response\r\n    if response.result.isSuccess {\r\n        print(response.result.value!)\r\n        \/\/ Perform your task here\r\n    } else {\r\n        \/\/ Handle error\r\n    }\r\n})<\/pre>\n<ol>\n<li>Create URLSessionConfiguration object and set it&#8217;s other properties<\/li>\n<li>Create object of SessionManager using \u00a0URLSessionConfiguration object. It internally use URLSession.<\/li>\n<li>Prepare\u00a0request using request method of SessionManager. You need to pass url, http method type, request body, encoding and header. It internally creates object of URLRequest and make an task and add it in request queue.<br \/>\nHere responseData have a completion handler. If request is completed and response is received then it calls the completion handler and remove that request from request queue.<\/li>\n<li>Check if data is received successfully. If yes, then do anything with your data.<\/li>\n<\/ol>\n<h3><strong>2. File Uploading with\u00a0<strong>and without <\/strong>Alamofire:<\/strong><\/h3>\n<p>File uploading with only URLSession is little bit complicated. In this you\u00a0need to prepare multipart request\u00a0by yourself.<\/p>\n<pre class=\"lang:swift decode:true \">let imageArray = [UIImage]()\r\nlet boundry = \"**********\"\r\nvar request = URLRequest(url: URL(string: \"http:\/\/api.imagga.com\/v1\/content\")!, cachePolicy: .reloadIgnoringCacheData, timeoutInterval: 40)\r\nrequest.httpMethod = \"POST\"\r\nrequest.addValue(\"multipart\/form-data; boundary=\\(boundry)\", forHTTPHeaderField: \"Content-type\")\r\n\r\n\/\/ Add Extra Parameters\r\nvar dataForm = Data()\r\ndataForm.append(\"\\r\\n--\\(boundry)\\r\\n\".data(using: .utf8)!)\r\ndataForm.append(\"Content-Disposition: form-data; name=\\\"param1\\\";\\r\\n\\r\\n10001\".data(using: .utf8)!)\r\n\r\n\/\/ Adding Images in multipart request\r\nif imageArray.count &gt; 0 {\r\n   for image in imageArray {\r\n      let timestamp = Date().timeIntervalSince1970*1000\r\n      let data = UIImageJPEGRepresentation(image, 0.6)\r\n      dataForm.append(\"\\r\\n--\\(boundry)\\r\\n\".data(using: .utf8)!)\r\n      dataForm.append(\"Content-Disposition: form-data; name=\\\"fileToUpload[]\\\"; filename=\\\"\\(timestamp).jpg\\\"\\r\\n\".data(using: .utf8)!)\r\n      dataForm.append(\"Content-Type: image\/jpeg\\r\\n\\r\\n\".data(using: .utf8)!)\r\n      dataForm.append(data!)\r\n   }\r\n}\r\ndataForm.append(\"\\r\\n--\\(boundry)--\\r\\n\".data(using: .utf8)!)\r\n\r\n\/\/ Create session and send multipart request\r\nlet urlSession = URLSession(configuration: URLSessionConfiguration.default)\r\nrequest.httpBody = dataForm\r\nlet uploadTask = urlSession.dataTask(with: request, completionHandler: { data, response, error in\r\n\r\n   let output = String(data: data!, encoding: .utf8)\r\n   print(output)\r\n   if error == nil {\r\n      DispatchQueue.main.async {\r\n         \/\/Upload successful\r\n      }\r\n   } else {\r\n      DispatchQueue.main.async {\r\n         \/\/Upload failled\r\n      }\r\n   }\r\n})\r\n\r\n\/\/ Upload request\r\nuploadTask.resume()\r\nurlSession.finishTasksAndInvalidate()\r\n<\/pre>\n<ol>\n<li>Make request object with caching policy and timeout. Define its http method.<\/li>\n<li>Add <strong>Content-type\u00a0<\/strong>in request body.<\/li>\n<li>Create data object for request body and add content boundary and other parameters.<br \/>\nNow Convert image into data and append boundary, content-type, file name, and file data in data object. Repeat it for all images or files. Append boundary in last.<\/li>\n<li>Create `<strong> URLSession<\/strong> ` object to send request.<\/li>\n<li>Add data in request body.<\/li>\n<li>Create task and start task execution.<\/li>\n<li>In completion handler of data task you get data, response and error. You can work anything with it.<\/li>\n<\/ol>\n<p>In the given code, you can not get progress for uploading.<br \/>\nIf you want to send a single file then you can use uploadTask of URLSession. But through this you can not send multiple files in single request. To send a single file you need to call given method:<br \/>\n<span class=\"s1\">`<strong>urlSession.<\/strong><\/span><strong><span class=\"s2\">uploadTask<\/span><\/strong><span class=\"s1\"><strong>(with: request, from: dataForm)<\/strong>`<br \/>\nThis method only send request and not let you if file is uploaded successfully. For that you need to implement `<\/span><strong><span class=\"s1\">URLSessionDataDelegate`\u00a0<\/span><\/strong><span class=\"s1\">methods to know the response and progress of \u00a0your request.<\/span><\/p>\n<p>File uploading with alamofire is very easy. Here you need not maintain any queue for task.<\/p>\n<pre class=\"lang:swift decode:true \">\/\/ convert image to data object\r\nguard let imageData = UIImageJPEGRepresentation(image, 0.5) else {\r\n   print(\"Could not get JPEG representation of UIImage\")\r\n   return\r\n}\r\n\r\n\/\/ send multipart request\r\nAlamofire.upload( multipartFormData: { multipartFormData in\r\n   multipartFormData.append(imageData, withName: \"imagefile\", fileName: \"image.jpg\", mimeType: \"image\/jpeg\")},\r\n\r\n      to: \"http:\/\/api.imagga.com\/v1\/content\",\r\n      headers: [\"Authorization\": \"Basic xxx\"],\r\n      encodingCompletion: { encodingResult in\r\n\r\n         \/\/ check the response\r\n         switch encodingResult {\r\n         case .success(let upload, _, _):\r\n            upload.uploadProgress { progress in\r\n               \/\/ Show progress\r\n            }\r\n            upload.responseJSON { response in\r\n               \/\/ Handle response\r\n            }\r\n         case .failure(let encodingError):\r\n               print(encodingError)\r\n               \/\/ Handle Error\r\n      }\r\n   })\r\n}<\/pre>\n<p>To upload the file you need to follow some easy steps:<\/p>\n<ol>\n<li>Convert your image or file in Data<\/li>\n<li>Call ` <strong>Alamofire.upload()<\/strong> ` method to upload data in multipart request. It appends your data and related information in multipartFormData and take url of server where you want to upload and header as argument. It maintains queue and send multipart request.<\/li>\n<li>In enclosingCompletion Handler, we receive result which tells whether it is success or failure. In success blog we can check the upload status.<\/li>\n<\/ol>\n<h3><strong>3. File Downloading\u00a0with\u00a0<strong>and without <\/strong>Alamofire:<\/strong><\/h3>\n<p>File downloading without Alamofire is a complicated task. Please have a look down:<\/p>\n<pre class=\"lang:swift decode:true\">func downloadFile() {\r\n   let urlSession = URLSession(configuration: .default, delegate: self, delegateQueue: nil)\r\n   let downloadRequest = urlSession.downloadTask(with: URL(string: \"http:\/\/wallpaper-gallery.net\/images\/image\/image-17.png\")!)\r\n   downloadRequest.resume()\r\n}\r\n    \r\nfunc urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {\r\n   \/\/ Handle error while downloading\r\n}\r\n    \r\nfunc urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL) {\r\n   let fileManager = FileManager.default\r\n   let urls = fileManager.urls(for: .documentDirectory, in: .userDomainMask)\r\n   let destURL = urls.first?.appendingPathComponent(\"test\").appendingPathExtension(\"pdf\")\r\n   let downloadedData = try? Data(contentsOf: location)\r\n   let _ = try? downloadedData?.write(to: destURL!)\r\n   \/\/ File has been downloaded. Do extra work here if you want.\r\n}\r\n    \r\nfunc urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didWriteData bytesWritten: Int64, totalBytesWritten: Int64, totalBytesExpectedToWrite: Int64) {\r\n   \/\/ show progress\r\n}<\/pre>\n<p>By Only URLSession you first create session configuration and then downloadTask with url and pass self as delegate. To get progress you need to confirm protocol `\u00a0<strong><span class=\"s1\">URLSessionDownloadDelegate\u00a0<\/span><\/strong>` and implement given three methods to get response success, error or progress.<\/p>\n<p>Using alamofire it\u00a0become easy to download any file.<\/p>\n<pre class=\"lang:swift decode:true\">let url = URL(string: \"http:\/\/wallpaper-gallery.net\/images\/image\/image-17.png\")\r\n\r\n\/\/ Send download request\r\nAlamofire.download(url!).response { (response) in\r\n   \/\/ Handle response\r\n   print(\"File: \\(response.temporaryURL ?? \"\")\")\r\n}.downloadProgress { (progress) in\r\n   let progress = progress.fractionCompleted * 100\r\n   print(progress)\r\n   \/\/ Show progress\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3><strong>4. Image Downloading and caching:<\/strong><\/h3>\n<p>For downloading and caching you can use AlamofireImage pod. Using this library you do not need\u00a0to cache\u00a0by yourself. This library will download and cache your images.<\/p>\n<p>For that you need to add AlamofireImage in your pod file and install it.<br \/>\nNow import it in your project.<br \/>\nCreate an object of\u00a0\u00a0`<strong>\u00a0<\/strong><span class=\"s1\"><strong>ImageDownloader\u00a0<\/strong>` add pass the given parameters:<\/span><\/p>\n<pre class=\"lang:swift decode:true\">let imageDownloader = ImageDownloader(\r\n  configuration: ImageDownloader.defaultURLSessionConfiguration(),\r\n  downloadPrioritization: .fifo,\r\n  maximumActiveDownloads: 4,\r\n  imageCache: AutoPurgingImageCache(\r\n    memoryCapacity: 2_000_000, \/\/ Memory in bytes\r\n    preferredMemoryUsageAfterPurge: 1_000_000\r\n  )\r\n)\r\n<\/pre>\n<p>Here you can pass download priority i.e. fifo or .lifo as you want, maximum concurrent downloads and object of AutoPurgingImageCaching which take caching memory capacity as argument.<\/p>\n<p>Now you can use that object of ImageDownloader to download image.<\/p>\n<pre class=\"lang:swift decode:true\">imageDownloader.download(urlRequest) { response in\r\n  var img = UIImage()\r\n  if response.result.value != nil {\r\n    img = response.result.value!\r\n  }\r\n}<\/pre>\n<p>This method first check your image in cache. If it exist then return the image else it download the image, add it in cache and return it.<\/p>\n<p>You can compare both the code and decide\u00a0which one you want to use.<\/p>\n<h3><strong>Steps to use Alamofire in your project:<\/strong><\/h3>\n<ol>\n<li class=\"p1\"><b>Import Alamofire:<br \/>\n<\/b>1. Add pod file using `<strong> pod init<\/strong> ` command in terminal.<br \/>\n2. Open pod file in editor and add given line in it:<br \/>\n`<strong>pod <span class=\"s2\">&#8216;Alamofire\u2019<\/span><\/strong>` \u00a0to add Alamofire library<br \/>\nor<br \/>\n` <strong>pod <\/strong><span class=\"s2\"><strong>&#8216;AlamofireImage<\/strong>\u2019\u00a0<\/span>` for image downloading and caching.<br \/>\n3. Open terminal add run command ` <strong>pod install<\/strong> ` to install library.<br \/>\nThis will add the latest version of Alamofire library in your project. Now you can use it.<\/li>\n<li class=\"p1\"><b>Use Alamofire in your project<\/b>:<br \/>\nWhen alamofire is installed in your project, so you can import it in your class where you prepare\u00a0and send request. The way to use this Library is given above. Enjoy you request and response data with alamofire. \ud83d\ude42<\/li>\n<\/ol>\n<p>For more information please visit:<\/p>\n<p><a href=\"https:\/\/github.com\/Alamofire\/Alamofire\">https:\/\/github.com\/Alamofire\/Alamofire<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Alamofire: Alamofire is a HTTP networking based library for iOS and macOS. It is used to handle HTTP request and response. It is the wrapper class of URLSession. Before Alamofire: You need to prepare all request by yourself Task handling is complicated Multipart request and File downloading &amp;\u00a0uploading is complicated Image caching needs to done [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3330,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,71],"tags":[202,201,183,178,28],"class_list":["post-2902","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ios","category-mobile","tag-afnetworking","tag-alamofire","tag-swift","tag-swift-3-0","tag-xcode"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Alamofire - InnovationM - Blog<\/title>\n<meta name=\"description\" content=\"Alamofire is a wrapper class of NSURLSession which is used to send http request and handle response easily\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.innovationm.com\/blog\/alamofire\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Alamofire - InnovationM - Blog\" \/>\n<meta property=\"og:description\" content=\"Alamofire is a wrapper class of NSURLSession which is used to send http request and handle response easily\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.innovationm.com\/blog\/alamofire\/\" \/>\n<meta property=\"og:site_name\" content=\"InnovationM - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2017-06-21T08:06:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2017\/06\/Alamofire-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"624\" \/>\n\t<meta property=\"og:image:height\" content=\"347\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"InnovationM Admin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InnovationM Admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/\"},\"author\":{\"name\":\"InnovationM Admin\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"headline\":\"Alamofire\",\"datePublished\":\"2017-06-21T08:06:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/\"},\"wordCount\":1042,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Alamofire-1.png\",\"keywords\":[\"AFNetworking\",\"alamofire\",\"Swift\",\"Swift 3.0\",\"Xcode\"],\"articleSection\":[\"iOS\",\"Mobile\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/\",\"name\":\"Alamofire - InnovationM - Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Alamofire-1.png\",\"datePublished\":\"2017-06-21T08:06:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\"},\"description\":\"Alamofire is a wrapper class of NSURLSession which is used to send http request and handle response easily\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Alamofire-1.png\",\"contentUrl\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/06\\\/Alamofire-1.png\",\"width\":624,\"height\":347},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/alamofire\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Alamofire\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/\",\"name\":\"InnovationM - Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/#\\\/schema\\\/person\\\/a831bf4602d69d1fa452e3de0c8862ed\",\"name\":\"InnovationM Admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g\",\"caption\":\"InnovationM Admin\"},\"sameAs\":[\"http:\\\/\\\/www.innovationm.com\\\/\"],\"url\":\"https:\\\/\\\/www.innovationm.com\\\/blog\\\/author\\\/innovationmadmin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Alamofire - InnovationM - Blog","description":"Alamofire is a wrapper class of NSURLSession which is used to send http request and handle response easily","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.innovationm.com\/blog\/alamofire\/","og_locale":"en_US","og_type":"article","og_title":"Alamofire - InnovationM - Blog","og_description":"Alamofire is a wrapper class of NSURLSession which is used to send http request and handle response easily","og_url":"https:\/\/www.innovationm.com\/blog\/alamofire\/","og_site_name":"InnovationM - Blog","article_published_time":"2017-06-21T08:06:07+00:00","og_image":[{"width":624,"height":347,"url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2017\/06\/Alamofire-1.png","type":"image\/png"}],"author":"InnovationM Admin","twitter_misc":{"Written by":"InnovationM Admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#article","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/"},"author":{"name":"InnovationM Admin","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"headline":"Alamofire","datePublished":"2017-06-21T08:06:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/"},"wordCount":1042,"commentCount":0,"image":{"@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2017\/06\/Alamofire-1.png","keywords":["AFNetworking","alamofire","Swift","Swift 3.0","Xcode"],"articleSection":["iOS","Mobile"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.innovationm.com\/blog\/alamofire\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/","url":"https:\/\/www.innovationm.com\/blog\/alamofire\/","name":"Alamofire - InnovationM - Blog","isPartOf":{"@id":"https:\/\/www.innovationm.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#primaryimage"},"image":{"@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#primaryimage"},"thumbnailUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2017\/06\/Alamofire-1.png","datePublished":"2017-06-21T08:06:07+00:00","author":{"@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed"},"description":"Alamofire is a wrapper class of NSURLSession which is used to send http request and handle response easily","breadcrumb":{"@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.innovationm.com\/blog\/alamofire\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#primaryimage","url":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2017\/06\/Alamofire-1.png","contentUrl":"https:\/\/www.innovationm.com\/blog\/wp-content\/uploads\/2017\/06\/Alamofire-1.png","width":624,"height":347},{"@type":"BreadcrumbList","@id":"https:\/\/www.innovationm.com\/blog\/alamofire\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.innovationm.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Alamofire"}]},{"@type":"WebSite","@id":"https:\/\/www.innovationm.com\/blog\/#website","url":"https:\/\/www.innovationm.com\/blog\/","name":"InnovationM - Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.innovationm.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.innovationm.com\/blog\/#\/schema\/person\/a831bf4602d69d1fa452e3de0c8862ed","name":"InnovationM Admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c99d9eece9dfbc82297cf34ddd58e9fe05bb52fe66c8f6bf6c0a45bfb6d7629?s=96&r=g","caption":"InnovationM Admin"},"sameAs":["http:\/\/www.innovationm.com\/"],"url":"https:\/\/www.innovationm.com\/blog\/author\/innovationmadmin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/2902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/comments?post=2902"}],"version-history":[{"count":0,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/posts\/2902\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media\/3330"}],"wp:attachment":[{"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/media?parent=2902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/categories?post=2902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.innovationm.com\/blog\/wp-json\/wp\/v2\/tags?post=2902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}