I have a kmm project, I am able to get the data from the kotlin version, but for iOS not.
The data from the repo that I am trying to get:
suspend fun getRestaurantsOrders(): CommonFlow<List<Order>> {
val userId = appService.currentUser!!.id
val restaurant = realm.query<Restaurant>("userID = $0", userId).first().find()!!
return withContext(Dispatchers.Default) {
realm.query<Order>("restaurantID = $0 && totalQuantity > 0 SORT(discount DESC)", restaurant._id.toString())
.asFlow().map {
it.list
}.asCommonFlow()
}
}
The way that I am trying to get data from ios:
func getOrdersList()
{
Task{
do{
try await repo.getRestaurantsOrders().watch(block: {orders in
self.restaurantActiveOrdersList = orders as! [Order] //breaks here
})
}catch{
print("error")
}
}
}
I am getting an exception break with code: Thread 4: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
Any idea what I am doing wrong? I am new at swift, thanks in advance!