Start/Stop animation

Hi
I want to be able to start, stop and step thru the action in my metal view. I have this button in my interface:

Button(action: { model.pause.toggle() }) 
{ model.pause ? Text("Run") : Text("Pause") }

and this property in my model

@Published var pause: Bool = false {
   didSet {
      metalView.enableSetNeedsDisplay = pause
      metalView.isPaused = pause
   }
}

On initialisation, my renderer sets ‘pause’ to true. And everything works! Yayyyy! The app starts with the metal view paused and I can toggle the action on and off using the button.

The only problem is that I get this new message in my console (which doesn’t appear when I omit this code):

BOOL _NSPersistentUIDeleteItemAtFileURL(NSURL *const __strong) Failed to stat item: file:///Users/tchelyzt/Library/Containers/fr.norme.ville.MyApp/Data/Library/Saved%20Application%20State/fr.norme.ville.MyApp.savedState/restorecount.plist**

fr.norme.ville.MyApp is the bundle identifier

Thanks for any assistance

I assume the code still works?

I was unable to get this message. To reproduce it, I used chapter 20, Fragment Post-Processing code, and, in MetalView.swift, I hijacked the fog switch by changing:

  func updateNSView(_ uiView: NSViewType, context: Context) {
    metalView.enableSetNeedsDisplay = options.fog
    metalView.isPaused = options.fog
    updateMetalView()
  }

There have been a number of other people who also have this message: Log Messages after upgrading to Xc… | Apple Developer Forums so I think it’s safe to ignore it as console noise.

Yes. Code still works and I’d already visited that forum page.
I hate ignoring warnings.
Thanks for looking at it.

1 Like