Skip to content

Instantly share code, notes, and snippets.

@pwc3
Created March 3, 2013 23:44
Show Gist options
  • 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