CoreStore
CoreStore copied to clipboard
CoreStore.fetchOne.where not working with Date
Point model have field
@NSManaged public var captured: Date
when I try
let points: [Point] = CoreStore.fetchAll(From<Point>()) // get all points
points array have many points fetched from database
let point = CoreStore.fetchOne(From<Point>().where(\.captured == points[0].captured))
I receive nil
but why?
how correctly get record by date?
pls, help me
How are you saving your Point
instances?
@JohnEstropia
CoreDataService.getDataStack({ (dataStack: DataStack?) -> Void in
if let _ = dataStack{
try? CoreStore.perform(synchronous: { (transaction) in
let p: Point = transaction.create(Into<Point>())
p.captured = captured
p.lat = lat
p.lng = lng
p.rideId = rideId
p.sended = sended
}, waitForAllObservers: true)
}
})
}
Are you sure CoreStore.fetchOne(_:)
is being called after CoreStore.perform(synchronous:)
?
Have you tried to use CoreStore.fetchAll(_:)
instead to see if the Point
is in the database at all?