首页 > 解决方案 > Getting memory leak in SwiftUI TextField

问题描述

There is memory leak in SwiftUI TextField when I start to type in it. When I monitor this leakage using instrument I realized that the leaked object is UIDelayedAction. The leakage increase when I type more in the TextField. Is there any way to fix this?

struct ContentView: View {
    @State private var value: String = ""
    var body: some View {
        VStack {
            Text(value)
            TextField("Test", text: $value)
        }
    }
}

enter image description here

标签: iosswiftxcodememory-leaksswiftui

解决方案


推荐阅读