Modify the code for Cocoa in OS X

Test is not yet