-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Can't set object of type 'Skin' to property of type 'Skin' #7435
Comments
Can you provide us a code sample and stack trace please? |
HI @jsflax, thank you for your quick response. Fatal Exception: RLMException here is my class where i got the crash, it is in the setSkin function class VideoSettings: BaseRealmObject, VideoSettingsScheme {
} |
@HovhannesPoghosyan it would be worth changing the logic inside of |
@leemaguire here is my update property, and don't get what logic should i change import RealmSwift extension Realm { |
Could you try: func setSkin(_ skin: SkinUi) {
let newSkin = Skin(skin.getId()).pull(skin)
// If VideoSettings is already managed you will have access to the realm.
try! realm.write {
self.skin = newSkin
}
} |
sorry @leemaguire i don't think that this is the thread issue and realm.write will fix everything |
Hi @HovhannesPoghosyan did you manage to solve your issue? |
no @leemaguire unfortunately i have not fixed this issue yet |
I also encountered this problem. @leemaguire @HovhannesPoghosyan my log: The point of collapse is here: The type is correct, but the check fails,why ? |
I have same problem. I simplified code for example. `
}` '
When trying this,
This is the error: *** Terminating app due to uncaught exception 'RLMException', reason: 'Can't set object of type 'Client' to property of type 'Client'' |
Just ran into the same issue. For me, this had to do with frozen realms. I was trying to use a frozen realm object as a backlink to another object. In order to resolve the issue, I had to thaw() the object first so that it was a live instance. |
Any updates on this? Running into the same issue |
Me too, any updates? |
The same issue |
The problem is solved |
I'm encountering the same issue but when using Here is my code to help reproduce this issue: import SwiftUI
import RealmSwift
final class Item: Object, ObjectKeyIdentifiable {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var title: String
@Persisted var ownerId: String
@Persisted var category: ItemCategory?
}
final class ItemCategory: Object, ObjectKeyIdentifiable {
@Persisted(primaryKey: true) var _id: ObjectId
@Persisted var name: String
@Persisted var ownerId: String
}
struct ItemDetailsView: View {
@ObservedRealmObject var item: Item
@ObservedResults(ItemCategory.self) var categories
var body: some View {
Picker("Category", selection: $item.category) {
Text("None").tag(nil as ItemCategory?)
ForEach(categories, id: \.self) { category in
Text(category.name)
.tag(Optional(category))
}
}
}
} I've tried using
Am I using the SwiftUI Picker with Realm wrong? |
Hi @matthewmorek, Thanks for the reproduction case, the usage of the picker looks correct. I'm investigating what the issue is on our end. |
@matthewmorek can you try: var body: some View {
Picker("Category", selection: $item.category) {
Text("None").tag(nil as ItemCategory?)
ForEach(categories, id: \.self) { category in
Text(category.name)
.tag(category.thaw())
}
}
} as a workaround for now? What's happening is that a frozen Realm object ( |
@leemaguire Hey, thanks for this workaround. It works well and I'm happy to use it until this is sorted out at your end! 👍🏻 |
@leemaguire a big thanks from me too, ran into exactly the same issue |
@leemaguire a big thanks from me too - I have been struggling with this issue for a whole day, before I came across your workaround. |
I have just met this issue and got resolved myself. My use case is that I want to assign an existing object A to a related property of another existing object B. try! realm.write {
existingObjectB.relatedProperty = relatedObjectA
} Both of them are coming from the database directly, which means that none of them is new. The solution: thaw both of them before any assignment, and then assign the thawed object A to the thawed object B. Hope it helps. |
@leemaguire Based on the above message, it sounds like this is a bug in the Realm client code (since you're talking about workarounds). Does MongoDB plan on fixing this soon? Like many others, I got bit by this recently and lost many hours trying to track down a solution. Thanks. |
I too experienced this and thanks the workout. Does the job |
I had the same issue ! Would it not help if the error was more descriptive, like "Can't set frozen object of type"X" to property of type "X". Leemaguire, thanks for posting a solution! |
@sipersso This comment is a hidden gem 💎! My issue was resolved once I thawed both objects in question. Thank you so much! |
@leemaguire I am using the workaround in a macOS app, but with many pickers the multiple |
This is very, very annoying, and the error message couldn't be more confusing as to what the issue actually is. |
How frequently does the bug occur?
Seen once
Description
I have some realm model which has another realm object as a property and i am getting the crash report from firebase , when i am trying to set the value of that property , with this error message "Can't set object of type 'Skin' to property of type 'Skin'"
Stacktrace & log output
No response
Can you reproduce the bug?
Not yet
Reproduction Steps
No response
Version
10.7.2
What SDK flavour are you using?
Local Database only
Are you using encryption?
No, not using encryption
Platform OS and version(s)
iOS 14.7.1
Build environment
Xcode version: ...
Dependency manager and version: ...
The text was updated successfully, but these errors were encountered: