O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

For the More Curious: Document-Based Applications Without Undo

The NSUndoManager for your application knows when unsaved edits have occurred. Also, the window is automatically marked as edited. But what if you have written an application and are not registering your changes with the undo manager?

NSDocument keeps track of how many changes have been made. It has a method for this purpose:

f​u​n​c​ ​u​p​d​a​t​e​C​h​a​n​g​e​C​o​u​n​t​(​c​h​a​n​g​e​:​ ​N​S​D​o​c​u​m​e​n​t​C​h​a​n​g​e​T​y​p​e​)​

The NSDocumentChangeType can be one of the following: ChangeDone, ChangeUndone, or ChangeCleared. ChangeDone increments the change count, ChangeUndone decrements the change count, and ChangeCleared sets the change count to 0. The window is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required