alamofire

How to convert json data from alamofire to swift objects

社会主义新天地 提交于 2019-12-06 08:01:17
hi there im making a photo viewer app in swift using swift 1.1 in xcode 6.2 i am a having trouble trying to convert json response from alamofire to swift objects.i have used swiftyjson library but it seems there is a compatibility issues.here is my model class import Foundation struct Photo { var name: String var filename :String var notes: String } here is my viewController import UIKit class ImageViewerTableViewController: UITableViewController { var photos = [Photo]() override func viewDidLoad() { super.viewDidLoad() Alamofire.request(.GET, "http://httpbin.org/get") .responseJSON { (_, _,

How to get the download progress in bytes using Alamofire 4?

守給你的承諾、 提交于 2019-12-06 07:49:36
问题 I'm currently working on an iOS project which requires me to download 10 different files at once. I know the file size and the size of all the files combined but I'm struggling to find a way to calculate the progress across all download tasks. progress.totalUnitCount = object.size // The size of all the files combined for file in files { let destination: DownloadRequest.DownloadFileDestination = { _, _ in let path = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory

Upload files using multipart request - Swift 4

六月ゝ 毕业季﹏ 提交于 2019-12-06 07:11:37
I have to upload files on server using multipart request. For network calls i am using Alamofire. What i have done so far is below Request Service: Multipart request:- let headers: HTTPHeaders = [ "Content-type": "multipart/form-data" ] let fileData = Filedata() // getting data from local path let URL = try! URLRequest(url: "https://SomeUrl/upload", method: .post, headers: headers) Alamofire.upload(multipartFormData: { (multipartFormData) in //multipartFormData.append(fileData, withName: "image", fileName: "image", mimeType: "image/png") multipartFormData.append(fileData, withName: "file") },

Disable Cache Alamofire iOS

社会主义新天地 提交于 2019-12-06 06:52:35
I'm trying to disable caching when making iOS requests using Alamofire. When I try to make a request to the server and then make a request while authenticated as a different user I get a 304 status code back. I've tried everything at this link , all of which don't work or result in errors. The backend is using Express.js to handle requests and Passport.js for user auth. Is the correct approach to disable caching on Alamofire and on the iOS application? Or is there something I can do to prevent this happening on the backend? Either way I'm not quite sure next steps for how to move forward.

Alamofire with google geocoding api

谁都会走 提交于 2019-12-06 06:34:20
In one of my apps I need to geocode address string. At first I considered using CLGeocoder . However, after I tried it I stumbled upon a problem which I described in this question. The solution was to use Google's Geocoding APIs instead. I have now switched to them and managed to get them working by having the following functions: func startConnection(){ self.data = NSMutableData() let urlString = "https://maps.googleapis.com/maps/api/geocode/json?address=\(searchBar.text!)&key=MYKEY" let linkUrl:NSURL = NSURL(string:urlString.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet

Swift/PHP How to display mysql data (json) in UITableView using Alamofire

巧了我就是萌 提交于 2019-12-06 05:58:58
I would like to create a TableView which return just one cell. Include in this cell three labels: id, username and category. This would result to let user to see his basic detail info. When I Run the APP, my UITableView still not showing any result (blank). Please anyone can review my code to make it works ? I can not see where I am wrong as I don't get any error in Xcode TableView Controller import UIKit import Alamofire class MyProfile: UITableViewController { var users = [MyProfileBasicData]() override func viewDidLoad() { super.viewDidLoad() } override func viewDidAppear(animated: Bool) {

Alamofire Request error only on GET requests

余生长醉 提交于 2019-12-06 04:32:29
问题 I'm working on transferring my project from AFNetworking to Alamofire. Really like the project. POST requests work just fine, however, I'm receiving this error when attempting to make a GET request. Here's some example code: class func listCloudCredntials(onlyNew onlyNew: Bool = true, includePending: Bool = true) -> Request { let parameters: [String: AnyObject] = includePending ? ["include_pending": "true"] : [:] let urlString = "https://myapp-staging.herokuapp.com/api/1/credntials" let token

Swift Alamofire + Promise catching

£可爱£侵袭症+ 提交于 2019-12-05 20:42:00
Folks, The following works except for the catch, xcode errors out with expected member name following '.' Is this the proper way to promisify with PromiseKit? All suggestions welcome! Thanks! @IBAction func loginButtonTapped(sender: AnyObject) { let email = userEmail.text! let password = userPassword.text! func onSuccess(success:Bool, message:String, token: String) -> Promise<Void> { if success { NSUserDefaults.standardUserDefaults().setBool(true, forKey: "isUserLoggedIn") NSUserDefaults.standardUserDefaults().synchronize() self.dismissViewControllerAnimated(true, completion: nil) } else { let

Alamofire upload huge file

安稳与你 提交于 2019-12-05 17:49:56
I am using Alamofire to upload assets (image/video) as multipart form data. It works fine for file sizes below 300MB (app). When I try to upload a file greater than 300MB, app crashes. if let video = self.avPlayerItem?.asset as? AVURLAsset { if let assetData = NSData(contentsOfURL: video.URL) { multipartFormData.appendBodyPart(data: assetData, name: "file", fileName: "video", mimeType: "video/mp4") // Execution stops here } } I also get the below message from Xcode How would I support uploading huge sized videos using Alamofire? Use Stream to upload instead of converting file to NSData which

ResponseSerializer 'cannot call value of non-function type 'NSHTTPURLResponse?'' with Swift 3

夙愿已清 提交于 2019-12-05 17:08:05
I had been using the following code without issue until updating to Xcode 8 beta 6. It is similar to this example from the Alamofire repository. This morning I updated my Alamofire library to the latest swift3 branch, which is now compatible with beta 6. It shows the error: Cannot call value of non-function type 'HTTPURLResponse?' A similar question exists here , but it is not based on the current version of Swift and Alamofire. From what I understand, this error is because it thinks that I am trying to return the Request property response instead of the function response(responseSerializer: