Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between UIView and NSView

what is the difference between UIView and NSView

like image 940
rithik Avatar asked Mar 12 '11 14:03

rithik


4 Answers

One other big difference is where the origin of the coordinates system is.

In NSView 0,0 is in the lower left with positive values of Y going up.

In UIView 0,0 is in the top left with positive values of Y going down.

like image 36
Ron Davis Avatar answered Oct 21 '22 15:10

Ron Davis


UIView is used on iOS (Cocoa Touch), NSView on Mac (Cocoa). Although they have a lot in common, under the hood there are a lot of differences. For example, a UIView is always backed by a CoreAnimation layer while a NSView is only if you explicitly call setWantsLayer:YES (and optionally provide your own layer before that). For more details, refer to the class references for UIView and NSView.

NSView is IMHO more complicated and has more features due to its legacy (the first version of NeXTStep was released in 1988, so NSView's original design was created in 1988 at the latest). Some features wouldn't make sense on iOS (like drag&drop and tooltips). UIView was a fresh start (in 2006 at the latest) and avoided some design problems of NSView (for example, as mentioned earlier, it's always using CoreAnimation backing instead of the three modes that NSView supports). It has a different feature set also because its used in a different environment (see multitouch support; wouldn't make sense in NSView).

like image 98
DarkDust Avatar answered Oct 21 '22 15:10

DarkDust


UIView is on the iPhone, NSView is not. Hence, NSView is for Mac Applications, UIView is for iPhone apps.

like image 3
Omar Avatar answered Oct 21 '22 13:10

Omar


UIView is used for Cocoa Touch (Framework for iOS devices) whereas NSView is used for Cocoa (Mac OS X)

like image 1
user635064 Avatar answered Oct 21 '22 13:10

user635064