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

@BlackbirdColumnObserver example doesn't work #21

Open
ajayjapan opened this issue Oct 8, 2023 · 0 comments
Open

@BlackbirdColumnObserver example doesn't work #21

ajayjapan opened this issue Oct 8, 2023 · 0 comments

Comments

@ajayjapan
Copy link

ajayjapan commented Oct 8, 2023

This example does not work.

struct MyView: View {
     // title will be of type: String?
     @BlackbirdColumnObserver(\MyModel.$title, primaryKey: 123) var title

     var body: some View {
         Text(title ?? "Loading…")
     }
}

The error I am getting is:
Value of optional type 'String?' must be unwrapped to a value of type 'String'

Weirdly this seems to work by using a !:

struct MyView: View {
     // title will be of type: String?
     @BlackbirdColumnObserver(\MyModel.$title, primaryKey: 123) var title

     var body: some View {
         Text((title ?? "Loading…")!)
     }
}

I think this happens when the column is an optional already:

  @BlackbirdColumn public var title: String?

This results in:

     @BlackbirdColumnObserver(\MyModel.$title, primaryKey: 123) var title : String??

Related to: 2f15d7f

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

1 participant