https://app.quicktype.io
и уже по готовой моделеAlamofire.request("", method: .get, parameters: parameters).validate().responseJSON { response in
let jsonDecoder = JSONDecoder()
switch(response.result) {
case .success:
if let data = response.data {
do {
let json = try jsonDecoder.decode(Model.self, from: data)
completion(json, nil)
} catch let error {
print("\n Json Error \n", error.localizedDescription)
}
....
navigationController?.interactivePopGestureRecognizer?.isEnabled = true
navigationController?.interactivePopGestureRecognizer?.delegate = nil
extension UINavigationController: UINavigationControllerDelegate {
open override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
}
public func navigationController(_ navigationController: UINavigationController, didShow viewController: UIViewController, animated: Bool) {
if responds(to: #selector(getter: self.interactivePopGestureRecognizer)) {
if viewControllers.count > 1 {
interactivePopGestureRecognizer?.isEnabled = true
} else {
interactivePopGestureRecognizer?.isEnabled = false
}
}
}
}
extension IAPManager: SKPaymentTransactionObserver {
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
for transaction in transactions {
switch transaction.transactionState {
case .deferred: break
case .purchasing: break
case .failed: print("failed")
case .purchased: print("purchased")
case .restored: print("restored")
}
}
}
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
guard let indexPath = tableView.indexPathForSelectedRow else { return }
DispatchQueue.main.async {
self.navigationController?.pushViewController(YOUR CONTROLLER, animated: true)
}
}
let audioFiles: [String: String] = [
"": "",
"": "",
"": "",
"":"",
]
var players : [AVAudioPlayer] = []
var volume = 0.0
// init () {
// for (name, ext) in audioFiles {
// let a1 = setupAudioPlayerWithFile(file: name as NSString, type:ext as NSString)
// players.append(a1!)
// }
// }
//
// required init?(coder aDecoder: NSCoder) {
// fatalError("init(coder:) has not been implemented")
// }
func setVolume(v:Double) {
volume = v
for audioPlayer in players {
audioPlayer.volume = Float(volume)
}
}
func playSound(i:Int)
{
let audioPlayer = players[i]
audioPlayer.play()
}
func setupAudioPlayerWithFile(file:NSString, type:NSString) -> AVAudioPlayer? {
let path = Bundle.main.path(forResource: file as String, ofType: type as String)
let url = NSURL.fileURL(withPath: path!)
var audioPlayer:AVAudioPlayer?
do {
try audioPlayer = AVAudioPlayer(contentsOf: url)
audioPlayer!.prepareToPlay()
} catch {
print("Player not available")
}
return audioPlayer
}
let picker = UIDatePicker()
var oneYearTime = TimeInterval()
oneYearTime = 365 * 24 * 60 * 60
let todeyDate = Date()
let oneYearFromToday = todeyDate.addingTimeInterval(oneYearTime)
// 2
et twoYearFromToday = todeyDate.addingTimeInterval(2 * oneYearTime)
// 3 Задаем пикеру диапазон
picker.minimumDate = oneYearFromToday
picker.maximumDate = twoYearFromToday
// 4
picker.countDownDuration = 2 * 60
// 5 Узнать какую дату выбрал юзер и сохранить ее
picker.addTarget(self, action: #selector(datePickerChenge(paramdatePicker:)), for: .valueChanged)