alamofire

Alamofire with localhost connection problems

纵饮孤独 提交于 2019-12-12 01:08:08
问题 I built a REST API with node.js and express and I am storing my data with mongodb. When I send different HTTP verbs to my localhost address (http://localhost:8080/) using the Postman application, everything works perfectly. Although, when I use Alamofire, for some reason I cannot connect to my localhost address. Here is my swift code: func alamofireTest() { let url = "http://localhost:8080/" Alamofire.request(.GET, url) .responseJSON { response in debugPrint(response) if let JSON = response

Alamofire + Swift in UICollectionView

≯℡__Kan透↙ 提交于 2019-12-11 23:51:09
问题 I had no idea how to parse JSON data using Alamofire. Right now I successfully request the data from web service. The problem is I'm not really sure how to embed/parse json (image) data into UICollectionView import UIKit import Alamofire class PopularViewController: UIViewController,UICollectionViewDataSource, UICollectionViewDelegate { var users: [AnyObject] = [] func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { //#warning Incomplete method

Programmatic .beginRefresh() not refreshing data in UITableView

夙愿已清 提交于 2019-12-11 19:46:24
问题 In my TableViewController, I have an @objc function that fetches data using Alamofire. The function is called by the refreshController when the user pulls down to trigger a pull refresh. The pull refresh is declared like so: let refreshControl = UIRefreshControl() tableView.refreshControl = refreshControl self.refreshControl!.addTarget(self, action: #selector(refresh(sender:)), for: .valueChanged) And the function it runs: @objc func refresh(sender:AnyObject) { let defaults = UserDefaults

How to append all elements from an element of JSON dictionary to an array with Alamofire and SwiftyJSON

我与影子孤独终老i 提交于 2019-12-11 17:09:38
问题 I am trying to append all closing prices from the most recent to the oldest available in a given JSON dictionary. The URL request that I'm using is the following: https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=AMZN&interval=60min&outputsize=full&apikey=5H2L6THH6BSCAMKO As you can see, the result is a dictionary ordered with the most recent dates and within that dictionary, there is various options, including the closing price. A little bit of it can be seen below. {

Image loading taking more time in swift

时光毁灭记忆、已成空白 提交于 2019-12-11 16:13:56
问题 I am working on an application, where I am loading some images from the server and showing it on table view using Alamofire. But the problem is it is taking so much time to load the image. I want to show the image, like a blurry image until the time image is not loading. Please, someone, help me. cell.profileImageView?.pin_setImage(from: URL(string: modelArray[indexPath.row])) 回答1: This one is the solution using Kingfisher pod. You can set an activity Indicator while image is loaded. let

Alamofire syntax for ecobee request

旧街凉风 提交于 2019-12-11 15:19:00
问题 I'm trying to find the correct syntax for calling ecobee's API from Swift 4 using Alamofire. Their cURL example: curl -H "Content-Type: text/json" -H "Authorization: Bearer ACCESS_TOKEN" 'https://api.ecobee.com/1/thermostat?format=json&body=\{"selection":\{"selectionType":"registered","selectionMatch":"","includeRuntime":true\}\}' The closest I've been to a solution is this func doRequest() { guard let url = URL(string: "https://api.ecobee.com/1/thermostat?format=json") else { return } let

Can not fetch data using Alamofire?

时光毁灭记忆、已成空白 提交于 2019-12-11 15:06:44
问题 I am trying to fetch data in my iOS app from my Django backend. In postman if I perform a GET request on the following URL http://127.0.0.1:8000/api/places/categories with the params being Key:"Authorization" Value: "Bearer access_token". I get a JSON response. Inside my app I am doing something like this with the help of Alamofire: let access_token = "123" let headers = ["Authorization": "Bearer" + access_token] Alamofire.request(self.categoriesUrl, method: .get, parameters:nil,encoding:

How to upload multipart image to server using Alamofire

十年热恋 提交于 2019-12-11 14:34:07
问题 Below mentioned is my method to upload a multipart image to the server but when I am trying to do so the app is crashing "unexpectedly found nill" But value of image is there as I am selecting it from photo library. func createCoupon(_ code: String, storeID: Int, description: String, terms: String, image: UIImage, startDate: String, endDate: String, couponDiscount: String, minimumDiscount: String, percentage: String, maximumDiscount: String){ let urlString = BaseURL + "create-coupon" let

Alamofire Error After updating to latest version

ⅰ亾dé卋堺 提交于 2019-12-11 14:28:40
问题 I am facing an issue an issue after updating to the latest version of Alamofire 4.x where by the myRequest.response (line 2) gives error 'Cannot call value of non-function type 'HTTPURLResponse?'. I have been using this code without any issues for quite some time. Can someone please help? let queue = DispatchQueue(label: "com.cnoon.manager-response-queue", attributes: DispatchQueue.Attributes.concurrent) let myRequest = Alamofire.request(myURL, method: .get, headers: headers) myRequest

Upload Array having base64String encoded multiple images using Alamofire

左心房为你撑大大i 提交于 2019-12-11 13:01:41
问题 I am working out to send multiple images to backend using Alamofire. I have got base64 strings of images added in a NSMutableArray. Now I am trying to send this array of strings to server but its not working. I have tried uploading a single image by this way and it works super cool but why not an array of images . Image Picking - func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { if let pickedImage = info