alamofire

Completion handler for Alamofire network fetch

丶灬走出姿态 提交于 2019-12-02 08:42:45
I am attempting to create a function which will return a list of custom objects, created from parsing JSON. I am using AlamoFire to download the content. I have written this function which, on success, creates an array of locations to be returned. However, the returns are always nil. My code is below: func fetchLocations() -> [Location]? { var locations : [Location]? Alamofire.request(.GET, myURL) .responseJSON { response in switch response.result { case .Success(let data): locations = createMapLocations(data) case .Failure(let error): print("Request failed with error: \(error)") } } return

Swift: download image from Internet and cache them doesn't work properly. need suggestions

梦想的初衷 提交于 2019-12-02 08:41:27
I am new to swift, and I am building an App that download images from the Internet and display in a UICollectionView, I can achieve this function successfully, however, it seems like overtime you scroll the screen, it downloaded the images again and again, which may causes a lot of data of the users. I found that I can use cache to solve this problem, but it didn't work, I think I did everything right, but seems the data didn't stored in the cache. here is the code, anyone can help me solve this? thanks var imageCache = [String: UIImage]() class ViewController: UIViewController { override func

how to parsing Json with SwiftyJson from woocommerce api?

谁说我不能喝 提交于 2019-12-02 08:32:45
I want to parse JSON using alamofire and swiftyjson I try get JSON(value) like this let headers: HTTPHeaders = [ "Authorization": "Basic Y2tfZTA1ZGNmMDkwNTNmODEyMGQwYTMyOGI4YzJkY2QzOTY5MmE5ZDAyNzpjc18zYzZiYWY2NTM0NDhkNDM4ZDM1ZDNmNDY5Nzg5ZGM2Y2VhZGRiZjNl", "Accept": "application/json" ] Alamofire.request("https://woo.demoapp.xyz/wp-json/wc/v2/products?category=15", headers: headers).responseJSON { response in debugPrint(response) if let json = response.result.value { print("JSON: \(json)") } } here is the JSON data from woocommerce api [ { "id": 29, "name": "Sunglasses", "permalink": "https:/

Inserting data into realm DB with progress?

醉酒当歌 提交于 2019-12-02 08:31:07
I have request data which was about 7MB after it has downloaded the json string,means the json string is about 7MB.After it has downloaded,I would like to save the data into realm model object(table) with progress like (1/7390) to (7390/7390) -> (data which is inserted/total data to be inserted) I am using Alamofire as HTTPClient at my app.So,how to insert data with progress into my realm object model after it has downloaded from server?Any help cause I am a beginner. I wont show the data model exactly,so,any example is appreciated.Let say my json string is. { { name : Smith, age : 23, address

swift基于Alamofire的简易封装整理

。_饼干妹妹 提交于 2019-12-02 08:28:22
// // BLHttpSessionsRequest.swift // ALSFinancial-Swift // // Created by 冰泪 on 16/8/23. // Copyright © 2016年 冰泪. All rights reserved. //网络请求类封装 import UIKit import Alamofire //创建请求类枚举 enum RequestType: Int { case requestTypeGet case requestTypePost } //创建一个闭包(注:oc中block) typealias sendVlesClosure = (AnyObject?, NSError?)->Void typealias uploadClosure = (AnyObject?, NSError?,Int64?,Int64?,Int64?)->Void class BLHttpSessionsRequest: NSObject { // --GET请求获取JSON数据 func BLGetJSONDataWithUrl(url: String, parameters: AnyObject, successed:(responseObject: AnyObject?) -> (), failed: (error: NSError?) ->

Display Nested array from JSON data to tableview using Alamofire

南笙酒味 提交于 2019-12-02 08:05:54
问题 I have displayed first json data in tableview but when trying to display array data of inner array data it's showing blank data on table view , I have tired many ways sometimes it showing me Index out of range don't know where i'am getting wrong or forget to write code , I'am able to display that Fees class data in table view but not able to display description data ,Or do i need to change my Ui desgin here i have model class class Fees { var Billno = String() var DateOfReciept = String() var

Alamofire4 migration, Apple Mach-O Linker (id) Error

给你一囗甜甜゛ 提交于 2019-12-02 07:50:31
After spending weeks migrating all my Alamofire code to AF4/Swift3, I finally fixed all the complier errors due to Alamofire Function changes, but now when I try to build a I get a whole bunch of these Apple Mach-O errors. There's at least 29 of them and they all have either Alamofire or AlamofireImage in them (aside from the last one which is "Linker command failed with exit code 1"). I don't have a clue of what to do here, I'll post any extra info needed, can anyone help me out here? edit: Here are the first 3 errors, I copied only the parts highlighted in red. I will post the full log if

Postman request to Alamofire request

允我心安 提交于 2019-12-02 07:48:59
I'm having no issues when I make the post request with POSTMAN but when I use alamofire I have issues. The post still goes through on the alamofire request but the data is not received the same way. What does an alamofire request look like that's the exact same as the following postman... Swift 2.x : typealias apiSuccess = (result: NSDictionary?) -> Void typealias apiProgress = (result: NSDictionary?) -> Void // when you want to download or upload using Alamofire.. typealias apiFailure = (error: NSDictionary?) -> Void // Normal http request with JSON response.. func callJSONrequest(url:String,

Alamofire framework not found(Xcode-8.2.1 and iOS 10.2)

这一生的挚爱 提交于 2019-12-02 07:34:53
问题 I have tried so many solutions out there but finally not getting what to do . I just installed cocoa pods for Alamofire and swiftyJson . And now when i clean and build my project i get an error NO SUCH FRAMEWORK ALAMOFIRE when I try import Alamofire in any swift file it says: NO SUCH MODULE ALAMOFIRE My Updated Podfile is something like this( No such framework Alamofire error is solved by this pod file). But still getting No such Module alamofire -: # Uncomment the next line to define a

TableView.reloadData() is not working ? (SWIFT)

回眸只為那壹抹淺笑 提交于 2019-12-02 06:43:57
问题 I am developing a Quiz App which fetches questions from a JSON. I have already used reloadData for TableView many times & worked as expected. But now I am fetching Questions using Alamofire & saving it in a Array & fetching the Questions from the Array. But it returns Array is Out of Index. How can i Display the First item of the Array in the first Cell ? VC class ExamController: UIViewController, UITableViewDataSource, UITableViewDelegate { @IBOutlet weak var Exam: UITableView! var CourseID