5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

SwiftUIでinit内でStateを変更しても反映されない

Last updated at Posted at 2021-02-03

コメントいただきよりよい方法見つかりました

@State var fullText: String // No default value of ""

init(letter: String) {
    _fullText = State(initialValue: list[letter]!)
}

以下更新前

init ないで Stateを変更してもUIに反映されませんでした。
ViewのonAppearでStateを変更すると反映されるようになりました。

参考
https://stackoverflow.com/questions/56691630/swiftui-state-var-initialization-issue

5
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?