2010年11月22日星期一

Few little technique on Objective-C

To test an object's type in runtime in Obj-C:

[myObject isKindOfClass:[NSString class]]

To get the mouse position on the screen:

NSPoint mouseLoc;
mouseLoc = [NSEvent mouseLocation];


To get the mouse position wrt local window:

NSPoint  point   = [self convertPoint:[theEvent locationInWindow] fromView:nil];

沒有留言:

發佈留言