0

I have a NSCollectionView I am trying to use with a SwiftUI application but need to access an ObservableObject (singleton) - I can access the singleton but can't seem to use Swift .observe nor can I find any reference to using ObservableObject from with the view controller.

Duncan Groenewald
  • 8,496
  • 6
  • 41
  • 76
  • 1
    Would you show your code of where is dependency between ObservableObject and your UIKit component (controller?) and what you want to observe? – Asperi Jun 29 '20 at 07:43
  • I have a NSViewControllerRepresentable embedded in a SwiftUI view with the main model object a singleton ObservableObject. Usually I would just use bindings or KVO but I just wonder whether it is possible to use the ObservedObject within the NSViewController - I can't find any specific mention that Combine will only work with SwiftUI. – Duncan Groenewald Jun 29 '20 at 20:59
  • For now I just turned the model object into a NSObject subclass and use KVO to observe properties. – Duncan Groenewald Jun 29 '20 at 21:01

0 Answers0