alamofire

How to upload multiple images in multipart using Alamofire?

六眼飞鱼酱① 提交于 2019-11-28 13:55:17
I am stuck in uploading multiple images in multipart using Alamofire. Can any one help me? Thanks in advance!! For more details, I am using this code to create body part of images data: func imageArrayToNSData(array: [UIImage],boundary:String) -> NSData { let body = NSMutableData() var i = 0; for image in array{ let filename = "image\(i).jpg" let data = UIImageJPEGRepresentation(image,0.8); let mimetype = "image/jpeg" let key = "product_images" body.appendData("--\(boundary)\r\n".dataUsingEncoding(NSUTF8StringEncoding)!) body.appendData("--\(boundary)\r\n".dataUsingEncoding

I won't be able to return a value with Alamofire in Swift

跟風遠走 提交于 2019-11-28 13:51:49
The current code I'm having doens't seem to return anything, I can't find out what is causing the issue. func getQuests(category: NSString, count: Int) -> NSArray { var quests = NSArray() Alamofire.request(.GET, apiUrlString, parameters: ["category": category, "count": count]) .responseJSON { (request, response, json, error) in dispatch_async(dispatch_get_main_queue(), { quests = json as NSArray }) } println(quests) #=> () return quests } Does anybody know how to solve the issue I'm having? [Update] : This is the status. Please look at the fifth and eight row. I can't get the assignment to

Synchronizing remote JSON data to local cache storage in iOS Swift

断了今生、忘了曾经 提交于 2019-11-28 13:16:48
问题 I am trying to find the solution for simple processing all necessary steps for read-only consuming remote JSON data on iOS devices. It means fetching remote JSON data, store to local cache on iOS device for offline usage, refresh the cache, parsing JSON data. I think it is very common requirement for all mobile apps nowadays. I know it is possible to manually download remote JSON file, store it to local db or file on iOS device and when network is not available fetch it from local storage

Why can't I get the request result form Alamofire

青春壹個敷衍的年華 提交于 2019-11-28 12:16:45
问题 I can't get the result of Alamofire request.So,I created ouput of an array that I got from json async call.I can't get the resultArray out of dispatch {...}.When I add println to debug the code.The second one appear first before the first one. All i want to resultArray to get the data from Alamofire to display in UIPickerView.Please Help!!! Here is my code import UIKit import Alamofire class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource{ @IBOutlet var

Swift - How to save memory using AlamofireImage/ImageShack?

半腔热情 提交于 2019-11-28 12:09:13
问题 I'm using Alamofire , AlamofireImage to cache images using ImageShack storage with Firebase backend. Sometimes memory comes over 100MB. I want to learn how to improve my image caching and well scaling before uploading. For example I have declared one common cache in class whole project using that AutoPurgingImageCache : let photoCache = AutoPurgingImageCache( memoryCapacity: 100 * 1024 * 1024, preferredMemoryUsageAfterPurge: 60 * 1024 * 1024 ) Is there any way to define these memoryCapacity ,

how to make alamofire download progress run in background ios?

纵饮孤独 提交于 2019-11-28 11:52:07
I am using Alamofire to download data How to make alamofire run download in background with swift? Thanks The basic idea is as follows: The key problem is that with background downloads, your app may actually be terminated while downloads are in progress (e.g. jettisoned due to memory pressure). Fortunately, your app is fired up again when background downloads are done, but any task-level closures you originally supplied are long gone. To get around this, when using background sessions, one should rely upon session-level closures used by the delegate methods. import UIKit import Alamofire

Cannot add Alamofire to Swift Project

对着背影说爱祢 提交于 2019-11-28 11:50:24
Trying to add alamofire to swift project using unstruction from here Did all these steps, clean project a lot of timer and restarted XCode, nothing helps. Error does not dissappear http://i.stack.imgur.com/kNU3R.png "Cannot load underlying module for 'Alamofire'" and nothing to do Changes I did: 1) added project file to my project i.stack.imgur.com/eUe8E.png 2) added to build phases panel i.stack.imgur.com/1wanl.png 3) added to general tab i.stack.imgur.com/L3TTR.png What`s wrong with that? I had the same problem. I was able to fix it by doing the following. Download the Alamofire "Source"

Capturing data from Alamofire

前提是你 提交于 2019-11-28 11:28:56
问题 I'm having trouble retrieving data from my Alamofire request asynchronously. class BookGetter { static let instance = BookGetter() func getBook(bookId: String) -> Book { let rootUrl = "https://www.someusefulbookapi.com/bookid=?" let url = rootUrl + bookId var title = "" Alamofire.request(.GET, url).response { response in let jsonDict = JSON(data: response.2!) title = String(jsonDict["items"][0]["volumeInfo"]["title"]) } let book = Book(title: title) print(book.title) return book } } The

Module 'Alamofire' has no member named 'request'

半世苍凉 提交于 2019-11-28 10:41:06
I'm new to iOS Development, I installed Alamofire as said in README, but I have this error as other users and I don't know how to solve it. Alamofire.xcodeproj -> Build Phases -> Complie Sources If (0 item) , then " [+] Alamofire.swift ". It's OK :) 2019 UPDATE If you have this error and you use 'alamofire5' branch just change Alamofire.request to AF.request . if you are using new Alamofire 5.xxx then you will use AF instead of Almofire it like that AF.upload(multipartFormData: <#T##(MultipartFormData) -> Void#>, to: <#T##URLConvertible#>) AF.request(<#T##url: URLConvertible##URLConvertible#>)

Parsing JSON using the new Swift 3 and Alamofire

笑着哭i 提交于 2019-11-28 10:01:42
I'm using Alamofire as HTTP library, since the update to Swift 3, how do you parse JSON based on the example below? Alamofire.request("https://httpbin.org/get").responseJSON { response in debugPrint(response) if let json = response.result.value { print("JSON: \(json)") } } respone.result.value is of Any object, and is very new and confusing. As you can see in Alamofire tests you should cast response.result.value to [String:Any] : if let json = response.result.value as? [String: Any] { // ... } Updated for swift 3 : if your response is like below, [ { "uId": 1156, "firstName": "Kunal",