Skip to content
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

Bool can't add to realm #62

Open
IAFung opened this issue Oct 26, 2021 · 4 comments
Open

Bool can't add to realm #62

IAFung opened this issue Oct 26, 2021 · 4 comments

Comments

@IAFung
Copy link

IAFung commented Oct 26, 2021

When Bool default value is 'true', can't save to realm
I changed the demo

struct ToDoItem: Realmable {
    var id = UUID().uuidString
    var text = ""
    var isCompleted = true //modified this default value
    
    static func primaryKey() -> String? {
        return "id"
    }
}

when I set the 'isCompleted' default value is true.
can't save the false to the realm

@arturdev
Copy link
Owner

Can you post an example code, please?

@IAFung
Copy link
Author

IAFung commented Oct 26, 2021

I used your Example
截屏2021-10-26 下午6 05 03
I just modified the isCompleted to true
Then run the demo
https://user-images.githubusercontent.com/13991864/138857898-986dc4db-272f-423e-8876-3d5967cad9bf.mov
The isCompleted can't set to false

@arturdev
Copy link
Owner

You're right. Currently, as a workaround, you can make an init method that takes it as true by default, and leave it false in the definition.

@DantePuglisi
Copy link

I got here because Realmable structs are requesting to create an empty init otherwise they don't comply to Realmable. What's the cause for the issue explain here (and the init issue too)? Maybe they're related @arturdev?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants