Here jsonObject we are getting array of dictionary object. Each dictionary represents one record in RLMIngredient collection.
With this statement realm.create([RLMIngredient].self, value: jsonObject, update: .modified) I am getting compiler error.
What is the procedure to insert array of json object to realm here other than for loop. Below snippet is not working
if let jsonObject = try? JSONSerialization.jsonObject(
with: data,
options: []
) as? [[String: AnyObject]] {
try? realm.writeAsync({
realm.create(RLMIngredient.self, value: jsonObject, update: .modified)
}, onComplete: { error in
print(error)
print("Realm onComplete - Time taken to Read JSON file and insert ingredients \(Date().timeIntervalSince(start) * 1000)")
})
}