alamofire

AlamofireObjectMapper not supporting ios8 when updating to swift 3?

左心房为你撑大大i 提交于 2019-12-01 13:14:00
问题 I tried to update my project to Swift 3, my project has support for ios8 as well. While trying to update the cocoapods, I am getting issue that AlamofireObjectMapper requires higher deployment target. On changing to ios9 the pods install without any error, but I still want to support ios8. Can anyone help on how this can be achieved? Thanks in advance. 回答1: EDIT Alamofire 4.1.0 Support for iOS 8.0 and macOS 10.10 is back! You cannot update to Swift 3 without dropping support for iOS 8, I'm

Multiple file upload with array of parameters using Alamofire

谁说胖子不能爱 提交于 2019-12-01 13:09:05
问题 i have array of parameters and array of images each set of parameter contain one and only one image.my code let imgData = UIImageJPEGRepresentation(imageView.image!, 0.2)! Alamofire.upload(multipartFormData: { multipartFormData in multipartFormData.append(imgData, withName: "fileset",fileName: "file.jpg", mimeType: "image/jpg") for (key, value) in params { multipartFormData.append(value.data(using: String.Encoding.utf8)!, withName: key) } }, to:URLUpdateProfile, method:.post, headers:headers)

Saving a photo and using it immediately

梦想的初衷 提交于 2019-12-01 12:46:59
问题 I have the following code for taking a photo and saving it to the camera roll. I need to be able to use it there and then after saving without having to go back into the gallery and selecting it. I haven't found any examples on how to do this. @IBOutlet weak var imagePicked: UIImageView! @IBAction func CameraBtn(sender: UIButton) { if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) { var imagePicker = UIImagePickerController() imagePicker.delegate =

WebService API Method in Swift 3 and Swift 4?

非 Y 不嫁゛ 提交于 2019-12-01 12:37:33
I am new to Swift iOS and i want to create a separate method in separate class(like NSObject ) of web services so that i can use it in any ViewController and parse any type of JSON response using NSURLSession and Alamofire . Could someone help me. class WebRequester: NSObject { static let shared = WebRequester() let session = URLSession.shared func request(urlStr:String, parameter:String, token:String? = nil, callback:@escaping (_ result:NSDictionary?, error:Error?) -> Void) { let url = URL(string: BaseURL + urlStr) debugPrint("=====================") debugPrint(url ?? "") debugPrint(parameter

Uploading multiple image files with Swift

北城余情 提交于 2019-12-01 12:22:12
Im using the following code to upload a single image to a server (with parameters), However I've been trying to upload multiple images, but could not get it to work Creating NSData objects (of images saved in temp directory). Using netdata class here func uploadData(){ //create image data objects let filemanager:NSFileManager = NSFileManager() let files = filemanager.enumeratorAtPath(tempPicPath) var counter:Int = Int() while let file: AnyObject = files?.nextObject() { imagePathCollection.append(tempPicPath + "/" + (file as NSString)) } //convert to data objects () for path in

Alamofire 2.0 and Swift 2 - Header is not working. See how to fix it

本秂侑毒 提交于 2019-12-01 12:14:18
问题 When I upgraded my project to swift 2 with Alamofire 2 headers stopped working without any errors in code. The reason is that headers are not working old style. // login with Alamofire 1 and Swift 1.2 - WITH HEADER func loginAlamofire_1(username:String) { manager.session.configuration.HTTPAdditionalHeaders = ["Authorization": "yourToken"] manager.request(.POST, "login_url", parameters: ["username" : username], encoding: ParameterEncoding.JSON) .response{ (request, response, data, error) ->

How to upload an image using alamofire multipart form data with basic authentication?

我只是一个虾纸丫 提交于 2019-12-01 11:31:06
问题 I am new in programming and in iOS development. I need to upload an image using Alamofire multipart form data, but I also need to input basic authentication header. in this thread Alamofire 4.0 Upload MultipartFormData Header, it seems similar to my problem, the code is like this to upload Alamofire.upload(multipartFormData:{ multipartFormData in multipartFormData.append(unicornImageURL, withName: "unicorn") multipartFormData.append(rainbowImageURL, withName: "rainbow")}, usingThreshold

How do I return something from AlamoFire?

最后都变了- 提交于 2019-12-01 11:23:06
import Foundation import Alamofire import UIKit import SwiftyJSON class APIClient: UIViewController { let loggedIn = false struct Constants{ static let Domain = "http://gogogo.com" } func authenticate() -> Bool{ println("Authenticating") if let access_token = FBSDKAccessToken.currentAccessToken().tokenString { let parameters = [ "access_token": access_token ] Alamofire.request(.POST, Constants.Domain+"/accounts", parameters: parameters).responseJSON { (req, res, json, error) in if(error != nil) { self.sendReturnToSplash() } else { let json = JSON(json!) println("\(json)") return true //This

How do I access a nested JSON value using Alamofire and SwiftyJSON?

大城市里の小女人 提交于 2019-12-01 10:49:25
I am trying to access nested JSON results using swiftyJSON and Alamofire. My print value is nill and I believe I am not doing this correctly. What should my parameters be? I am trying to get the quote value located at http://quotes.rest/qod.json func getAPI() { Alamofire.request(.GET, "http://quotes.rest/qod.json", parameters: ["contents": "quotes"]) .responseJSON { response in if let JSON = response.result.value { print(JSON["quote"]) } } } In your JSON quotes is an array so if you want to access quote of the first object you should do it by accessing first object: func getAPI() { Alamofire

Extra argument 'method' in call of Alamofire

喜欢而已 提交于 2019-12-01 10:42:59
I've searched for this issue and there are many answers available but none are solving. I've defined parameters as: let parameters = [ "name": username, "mobile": "", "email": email, "password": "", "blood_donor": "0", "registration_id": defaults.string(forKey: "FCMToken"), "platform": platform, "appID": "3" ] And after that when I send the request: Alamofire.request(url, method: .post, parameters: parameters, encoding: URLEncoding(), headers: headers).responseJSON { response in So I get a warning on parameters Expression implicitly coerced from 'String?' to Any and if I put ! next to