3
3

More than 1 year has passed since last update.

はじめに

onChangeで古い値を使いたくなったのでやり方を調べたら可能そうだったので記録しておきます。

実装

import SwiftUI

struct ContentView: View {
    @State private var text = ""
    var body: some View {
        TextField("", text: $text, axis: .horizontal)
            .onChange(of: text) { [text] newValue in
                print("古い値:", text)
                print("新しい値:", newValue)
            }
    }
}

おわり

こんなことできるの知りませんでした

参考記事

3
3
0

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
3
3