This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Alamofire.request("Some URL", parameters: ["Some": "Param"]) | |
.response( | |
responseSerializer: DataRequest.jsonResponseSerializer(), | |
completionHandler: { response in | |
/* | |
You are now running on the main queue | |
*/ | |
//Then you parse to objects | |
//Do any manipulation if needed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let queue = DispatchQueue(label: "com.response-queue", qos: .utility, attributes: [.concurrent]) | |
Alamofire.request("Some URL", parameters: ["Some": "Param"]) | |
.response( | |
queue: queue, | |
responseSerializer: DataRequest.jsonResponseSerializer(), | |
completionHandler: { response in | |
/* | |
You are now running on the queue you created. So you | |
can parse the response to model objects or do any | |
other handling if necessary. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct QuotesResponse : Decodable { | |
//This is our daynamic key structure | |
struct QuotesKey : CodingKey { | |
var stringValue: String | |
init(stringValue: String) { | |
self.stringValue = stringValue | |
} | |
var intValue: Int? { return nil } | |
init?(intValue: Int) { return nil } | |
//we know what is "inside" this key (container) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Quote : Codable { | |
var time: String | |
var open: String | |
var high: String | |
var low: String | |
var close: String | |
var volume: String | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Toy : Codable { | |
let id: Int | |
let availableAt: String | |
let ageRange: String? | |
enum CodingKeys: String, CodingKey { | |
case id | |
case availableAt = "available_at" | |
case ageRange = "range" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************** | |
My cell has a label and under it a collection view with varying number of buttons in different sizes | |
So I'm letting Autolayout set the position of things and then taking all heights together for the cell height size | |
*************/ | |
class ButtonCollectionCell: UITableViewCell { | |
@IBOutlet weak var titleLabel: UILabel! | |
@IBOutlet weak var collectionViewDistanceFromCellBottomConstraint: NSLayoutConstraint! | |
@IBOutlet weak var distanceBetweenCollectionToLabelConstraint: NSLayoutConstraint! | |
@IBOutlet weak var buttonsCollectionView: UICollectionView! |