You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MBTAPrediction: Resource {
@objc dynamic var arrivalTime: String?
@objc dynamic var route: MBTARoute?
override static var resourceType: String {
return "prediction"
}
override class var codingKeys: [String : String] {
return [
"arrivalTime": "arrival_time"
]
}
}
class MBTARoute: Resource {
@objc dynamic var long_name: String?
@objc dynamic var short_name: String?
override static var resourceType: String {
return "route"
}
}
The following code fails because the related route object is nil.
guard let url = Bundle.main.url(forResource: "mbta_predictions", withExtension: "json"),
let data = try? Data(contentsOf: url) else {
fatalError()
}
let deserializer = Deserializer.Collection<MBTAPrediction>()
do {
let document = try deserializer.deserialize(data: data)
let predictions = document.data
let routeDesc = predictions?.first?.route?.long_name
// routeDesc should not be nil
} catch {
NSLog("Error deserializing MBTA response: \(error)")
}
@aronbalog I found that if I put a break point inside of the ResourcePool where each resource is added and step through slowly, it makes the code work. So I think this maybe some sort of async race condition.
If I'm just doing something wrong, please let me know. Thanks!
The text was updated successfully, but these errors were encountered:
@nbonatsakis Until I find appropriate solution, I suggest that you always retain Document<T> object. Removing this object from memory will cause unexpected side-effects at this moment. I'm having few solutions on my mind. Stay tuned.
@nbonatsakis Until I find appropriate solution, I suggest that you always retain Document<T> object. Removing this object from memory will cause unexpected side-effects at this moment. I'm having few solutions on my mind. Stay tuned.
Hi , We're waiting for you to push update and fix this holy bug 😑
@aronbalog we are using your library on a couple of real world projects. Would be great if you can share your thoughts on memory management for documents and high level description of whats wrong with them. I appreciate your work and can spend some time to build a fix.
I'm not sure if this is a bug or if it's an issue with how I'm using the lib, but I can't seem to get related objects to populate correctly.
Given the following JSON:
And these resource classes:
The following code fails because the related
route
object is nil.@aronbalog I found that if I put a break point inside of the
ResourcePool
where each resource is added and step through slowly, it makes the code work. So I think this maybe some sort of async race condition.If I'm just doing something wrong, please let me know. Thanks!
The text was updated successfully, but these errors were encountered: