2 ms·
It's OK, but I wouldn't call it great. It's readable, but sort of hard to use. The trouble is that the interface is too flexible, more so than the underlying co
by mikeash 11y ago
It's OK, but I wouldn't call it great. It's readable, but sort of hard to use. The trouble is that the interface is too flexible, more so than the underlying code, and so it's hard to know which combinations of parameters are legal. If you ask for a disallowed combination, you just get nil back and no explanation.
Edit: wrong API! This one does have a pixel format object.
It also tries to be helpful and so doesn't require all parameters. If you don't give it a data pointer, it will allocate memory for you. If you don't give it bytesPerRow, it will calculate it for you. These ought to be separate calls, not all glued together into one gigantic do-everything call.
The verbosity itself is fine, but it's symptomatic of some suboptimal API design behind it.
- rbritton 11y agoThough it's a C API, CGBitmapContextCreate is notorious for this. While it doesn't address everything you're alluding to, I'm a big fan of Swift's nonnull/nullable making its way into Objective-C since some of Apple's APIs don't play well with a nil parameter (e.g., -[NSString isEqualToString:]).