cocoa: fleshing out event loop implementation