Thursday, August 11, 2022
HomeiOS Developmentios - Unavailable property with a property wrapper

ios – Unavailable property with a property wrapper

My app has assist for iOS 14 and up, however I wish to use among the SwiftUI 3 property wrappers like @FocusState.

How can I work across the Saved properties can't be marked doubtlessly unavailable error?

Right here is the simplified model of my code, it really works with Xcode 13, however fails to compile with Xcode 14.

struct MyView: View {
  enum Subject: Hashable {
    case username

  @State personal var myText: String = ""

  @out there(iOS 15, *)
  @FocusState personal var focusedField: Subject?

  var physique: some View {
    if #out there(iOS 15, *) {
      TextEditor(textual content: $myText)
        .targeted($focusedField, equals: .username)
    } else {
      TextEditor(textual content: $myText)

I can not use a computed property with a backing storage workaround as a computed property can not have a property wrapper.

Are there some other workarounds that I can use aside from an nearly equivalent copy of MyView?



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments