Skip to content

Instantly share code, notes, and snippets.

@onevcat
Created September 20, 2012 09:27
Show Gist options
  • Save onevcat/3754895 to your computer and use it in GitHub Desktop.
Save onevcat/3754895 to your computer and use it in GitHub Desktop.
local block
// Use the __block storage modifier to allow changes to 'price'
__block float price = 1.99;
float (^finalPrice)(int) = ^(int quantity)
{
return quantity * price;
};
int orderQuantity = 10;
price = .99;
NSLog(@"With block storage modifier - Ordering %d units, final price is: $%2.2f", orderQuantity, finalPrice(orderQuantity));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment