Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
- (void)setArray:(NSArray *)anArray
_myArray = anArray; // aha! subtle bug because anArray MAY be a mutable array, so you need to do [anArray copy]. With the magic of inheritance, the type system becomes confusingly worthless, telling you that yes, a mutable array is an immutable array. Yay for confusing first time programmers!
// This problem exists EVERYWHERE:
- (void)doSomethingWithView:(NSView *)aView
[aView addSubview:controlView]; // This may or may not work depending what aView is. Despite the docs telling you that addSubview is a perfectly fine PUBLIC API, subclasses of NSView may make it effectively private, thus breaking here. So what's the point of saying "give me a view" if subclasses of NSView can willy-nilly change the exposed API?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment