Recipe 11-3 works by requesting
kqueue notifications in its
beginGeneratingDocument-NotificationsInPath: method. Here, it retrieves a file descriptor for the path you supply (in this case, the Documents folder) and requests notifications for add and clear events. It adds this functionality to the current run loop, enabling notifications whenever the monitored folder updates.
Upon receiving that callback, it posts a notification (for example, the custom
kDocument-Changed, in the
kqueueFired method) and continues watching for new events. This all runs in the primary run loop on the main thread, so the GUI can respond and update itself upon receiving the notification.
The following snippet demonstrates how you might use ...