问题
Mac app development is rumored to be very similar to iOS app development, but of course there are big differences.
When we put all the facts about hardware and screen constraints aside, what are the biggest obstacles an experiences iOS app developer must overcome to start with Mac app development?
Some of the awful things I've heard:
Myth 1: On the Mac, the coordinate system is different. 0 is at the bottom left. Feels like driving on the wrong side of the street.
Myth 2: NSView is not really like UIView. UIView always has a CALayer. NSView doesn't.
Myth 3: Table Views on the Mac are far more complex and harder to use than UITableView on iOS.
Can someone debunk them, or add a few others? Where are the painful differences in the APIs?
回答1:
1 and 2 are absolutely true. 3 is debatable - some things about NSTableViews are nicer, such as how you can use any object (e.g. a string, image, number) as a cell value.
Whilst we're on the subject of cells though, that's another pain - many NSViews have cell properties that do the real work, so the view hierarchy is mirrored by a cell hierarchy that makes everything more complex. Text fields are really confusing because of this.
Also, NSLabels/NSButtons can hardly do anything compared with UILabels/UIButtons - no font setting, no colour setting, no customisation at all - they're basically useless.
And if you do use Core Animation, it's poorly integrated with views. So for example you can transform an NSView in 3D if it's backed by a CALayer, just like in UIKit, but if you try to click on it, the mouse co-ordinates aren't mapped by the same transform as the view appearance, so if you transform a control it basically becomes un-clickable unless you click where it was originally positioned on screen before you transformed it.
Basically the whole of the Mac OS SDK feels like it was an early alpha version of the iOS SDK that hasn't been properly tested and where some of the stupid, overcomplicated ideas (cells) that didn't make it into production haven't been taken out yet.
</rant>
来源:https://stackoverflow.com/questions/9018076/what-are-the-biggest-obstacles-to-overcome-when-switching-from-ios-app-developme