Skip to content

Instantly share code, notes, and snippets.

@pwc3
Created March 3, 2013 23:44
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 pwc3/5078925 to your computer and use it in GitHub Desktop.
Save pwc3/5078925 to your computer and use it in GitHub Desktop.
Type checking assignments.
NSDictionary *aDictionary = nil;
NSArray *anArray = nil;
void (^aBlock)() = ^{ };
// no warning
aDictionary = aBlock;
// no warning
anArray = aBlock;
// warning assigning NSArray to NSDictionary, but not for block assignment
aDictionary = anArray = aBlock;
// Similarly:
id anUntypedObject = nil;
// no warning
aDictionary = anUntypedObject;
// no warning
anArray = anUntypedObject;
// warning assigning NSArray to NSDictionary, but not for block assignment
aDictionary = anArray = anUntypedObject;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment