Cocoa: Getting the current mouse position on the screen

The author’s original code does not work because s/he is attempting to print floats out as %d. The correct code would be:

NSPoint mouseLoc = [NSEvent mouseLocation]; //get current mouse position
NSLog(@"Mouse location: %f %f", mouseLoc.x, mouseLoc.y);

You don’t need to go to Carbon to do this.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)