Skip to content

Instantly share code, notes, and snippets.

@tolmasky
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolmasky/00eaa5e056b6637b7c18 to your computer and use it in GitHub Desktop.
Save tolmasky/00eaa5e056b6637b7c18 to your computer and use it in GitHub Desktop.
- (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