Я получаю результаты с Alamofire
из API
, как показано ниже:
let urls = URL(string: url)!
var urlRequest = URLRequest(url: urls)
urlRequest.addValue("application/json", forHTTPHeaderField: "Content-Type")
Alamofire.request(urlRequest).responseString { (response) in
if response.result.isSuccess{
do{
let jsonDecoder = JSONDecoder()
let response = try jsonDecoder.decode(CoursesModelBase.self, from: response.data!)
if response.status != nil{
//How can I immediately save results here???
}catch{
}
}
}
И как я могу сразу сохранить все результаты в sqlite, как Architect components
в Android?
Мой заказ objects
похож на приведенный ниже:
{
"status": 1,
"result": {
"cohorts": [
{
"id": 383,
"name": "AAAAA",
"course_category_id": null,
"language_symbol": "ar",
"live_start_date": null,
"live_end_date": null,
"live_start_time": null,
"live_end_time": null,
"type": "long_term",
"ctype": "offline",
"image_url": null,
"course_category_name": null,
"have_certificate": null,
"is_free": null
},
{
},
{
}.....
],
"categories": [
{
"id": 28,
"name": "BBBBB",
"parent_id": null,
"en": null,
"tr": null,
"fr": null,
"de": null,
"ar": null,
"az": null,
"ur": null,
"sw": null,
"ru": null,
"ha": null,
"ind": null,
"cn": null,
"jp": null
},
{
}....
],
"languages": [
{
"id": 1,
"name": "English",
"symbol": "en",
"isltr": "0"
},
{
}....
]
}
}
Я использую VIP-архитектора в своем проекте.