Closed phatblat closed 7 years ago
Ok will look into, I am sure I can find a way to convert between the types.
Too bad Realm isn't casting to RLMObjectBase
as it's a common super class.
RealmSwiftObject
== RealmSwift.Object
What's the reason that these cache objects extend RLMObject
? Seems like they aren't part of the schema and don't need to be persisted, just stored temporarily in memory.
Nevermind. I see now that they are being stored in a cacheRealm
.
This is actually an odd bug because typically at Realm we don't recommend to mix ObjC and Swift together, so the ObjC class definition actually doesn't play nice with the objectTypes
getter in the Realm Swift framework. However, what's ironic is that you wouldn't actually hit this when using RBQFetchedResultsController
as a framework because the cache object models would be isolated in the framework.... however, in the Swift example the files are included directly in the project!
Ok this is really ugly but using Swift's limited reflection here is how I could get around it:
// Hack to get around issue with cache objects appearing in Realm
// when building RBQFRC not as a framework
let mirror = Mirror(reflecting: configuration)
for child in mirror.children {
if "customSchema" == child.label {
let customSchema = child.value as! RLMSchema
let schemaSubset = customSchema.objectSchema.filter({ (objectSchema) -> Bool in
let cacheObjectNames = ["RBQControllerCacheObject",
"RBQObjectCacheObject",
"RBQSectionCacheObject"]
if cacheObjectNames.contains(objectSchema.objectName) {
return false
}
return true
})
rlmConfiguration.objectClasses = schemaSubset.map { $0.objectClass }
}
}
With my change this should be good to go to merge 👍
We can remove this hack once a new release of Realm Swift is released that exposes converter functions to support interoperability of Swift and ObjC Realm objects: https://github.com/realm/realm-cocoa/blob/master/RealmSwift/ObjectiveCSupport.swift#L139-L147
Barring surprises, we're planning on releasing Realm Swift 2.1.1 today.
2.1.1 is out: https://github.com/realm/realm-cocoa/releases/tag/v2.1.1
Let's get this fix in for backwards compatibility and then update to use new 2.1.1 APIs
Sounds good
LGTM. Thanks everyone for helping with this long-running PR!
👏🎉🎉
Ran the Swift 3 migration tool and updated the RealmSwift API for the changes in master.
master
branch of realm-cocoaWill redo submodule commit after dependent PR is merged.Dependendencies now integrated using CocoaPods instead of git submodules
Fixes phatblat/RBQFetchedResultsController#1