4 ms·
Hope significant are the differences between cocoa and uikit? I don't have any experience besides some light source browsing and it seemed the big difference is
by nxc18 8y ago
Hope significant are the differences between cocoa and uikit? I don't have any experience besides some light source browsing and it seemed the big difference is the NS to UI prefix change. Anyone care to summarize for the unenlightened?
- Klonoar 8y agoThe differences are more in implementation than anything else: - AppKit isn't layer-backed by default, requiring you to handle this. Something as simple as setting the background color for an NSView is far more of a ritual than it is for a UIView. - NSColor/NSImage under the hood are different than UIColor and UIImage. - NSTableView and NSCollectionView have big differences (NSCollectionView is more subtle, I should say) that rear their head when you start trying to do anything like you would on iOS. e.g, NSTableView doesn't automatically get an NSScrollView, grouped rows operate like headers but the underlying data structure isn't easy to share, collection view items are view controllers on macOS but not on iOS, etc. - Delegate methods are entirely different, requiring you to #if check everywhere. - Trying to use NSTextField like a UILabel is a trip, requiring you to understand an archaic NSCell architecture that you'll wish you didn't have to deal with in 2018. The list goes on, and most developers that share code between iOS and macOS have their own frankenstein framework floating around. UIKit on macOS would do a lot to alleviate this. Edited because, speaking of 2018... this should not be this annoying to format.
- reificator 8y agoSimilar to some markdown parsers, you need to have multiple newlines in the source in order for the presentation to have a newline. EDIT: Looks like you got there before I finished typing.
- jonhendry18 8y ago"Something as simple as setting the background color for an NSView is far more of a ritual than it is for a UIView." Or you just use an NSBox as the rearmost subview of the NSView, and set its fill color.
- wingerlang 8y agoI suspect that is exactly the kind of ritual he was talking about.
- Klonoar 8y agoYuuuuup. Cocoa developers tend to think it's all very apparent though. Was actually counting down until a comment like that appeared. ¯\_(ツ)_/¯
- jonhendry18 8y agoNot much of a ritual, really. Couple lines of code. Just a common case of using a UI widget in a way that isn't really done on UIKit.
- Klonoar 8y agoSo is the half-assed approach of working with the layer background. ;P That's what a ritual is; it's 2018 and I should not have to go out of my way to set a damn background color on a view. UIView has predictable behavior, AppKit does not.
- Klonoar 8y agoAlso, just to follow up on my original comment... from what I saw over on Twitter, 10.14 finally implicitly layer-backs apps by default, so the first point becomes much less of a nuisance than it used to be. Apps have to be linked against 10.4, mind you, but yeah. Props to Apple for finally fixing it.
- jurip 8y agoI prefer working with UIKit too, but there are reasons for some of the differences. Jeff Nadeau, an AppKit engineer, wrote a bit about them a couple of weeks ago: https://gist.github.com/jnadeau/9321a22b19301215e25401ffd1f165ab https://gist.github.com/jnadeau/9321a22b19301215e25401ffd1f1...
- Klonoar 8y agoYup, I follow him on Twitter. :) Regardless of how correct he probably is, the fact of the matter is that there's overwhelmingly more developers on the UIKit side and that API is what people clearly prefer - the only ones voicing otherwise are old Cocoa-heads. It's ridiculous that it's 10 years later and Apple is only now confronting this.
- deleted 8y ago[deleted]
- DelightOne 8y agoCocoa bindings in UIKit would be nice to see.