Swift:反斜杠点"\"的作用是什么.意思是?
2022-05-18 本文已影响0人
ONE2
swift key path expression \MyViewModel.filterString
let sub = NotificationCenter.default
.publisher(for: NSControl.textDidChangeNotification, object: filterField)
.map( { ($0.object as! NSTextField).stringValue } )
.filter( { $0.unicodeScalars.allSatisfy({CharacterSet.alphanumerics.contains($0)}) } )
.debounce(for: .milliseconds(500), scheduler: RunLoop.main)
.receive(on: RunLoop.main)
.assign(to:\MyViewModel.filterString, on: myViewModel)

What is a KeyPath in Swift
https://sarunw.com/posts/what-is-keypath-in-swift/