New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object property is unreachable in the realm result #4
Comments
Hi @waltcow Does the count of result continue to be 0? |
func getTweets(spaceId: Int, limit: Int = 15) -> [Tweet] {
let result: RealmQuery<Tweet> = query(filter: "spaceId == \(spaceId)", sortProperty: "id", ordering: .ascending)
var data = [Tweet]()
for i in 0 ..< min(limit, result.count) {
data.append(result[i])
}
return data
} fetch result from realm cast model to viewModel in a dictionary key key model id problem is the realm model property is still unreadable though i try to access it |
Is the "realm model property" that you want to approach is Realm class in RealmSwift? UserRealmManager().transaction(writeHandler: { (realm) in
// Here you can access the realm.
}) or let configuration = UserRealmManager().createConfiguration()
let realm = try! Realm(configuration: configuration) Is that what I understand? If not, please explain what "realm model property" you want to approach. |
class Tweet: Object, Mappable {
@objc var id: Int = -1
@objc var spaceId: Int = -1
@objc var content: String?
@objc var userId: Int = -1
....
} After i change my model definition to the follow, it works fine. @objcMembers
class Tweet: Object, Mappable {
dynamic var id: Int = -1
dynamic var spaceId: Int = -1
dynamic var content: String?
dynamic var userId: Int = -1
....
} |
Hi. I have some question about the realm result property, this is my first time to use realm
When my service code want to fetch user from realm, the result is not nil, but the property from this realm object is still unreachable(empty) in the view render process. it's so weird.
The text was updated successfully, but these errors were encountered: