views:

21

answers:

1

How would it be possible to invoke a method at the end of Cocoa's main event loop after each iteration? I want to do the exact same thing that NSManagedObjectContext's -processPendingChanges does. According to the documentation, "In AppKit-based applications, this method is invoked automatically at least once during the event loop (at the end of the loop)." I need to do the same thing for one of my own methods. Is this possible? I've read documentation about NSRunLoop and NSApplication's -run method, but I haven't been able to find the solution to this problem. Any help would be much appreciated.

A: 

I believe you can achieve what you want by installing a CFRunLoopObserver. You can get the current CFRunLoopRef via CFRunLoopGetCurrent() or from an NSRunLoop via -[NSRunLoop getCFRunLoop].

Barry Wark