2

I just discovered this construct, in ObjectiveC (probably works in C as well, I guess):

self.versionLabel.text = ({
    NSString *version = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
    [NSString stringWithFormat:NSLocalizedString(@"Version", nil), version];
});

Where the value assigned to versionLabel.text is the value of the last line of the block.

But this is not really a "block" as we call them in ObjC... Any idea how we name that construct?

aspyct
  • 3,625
  • 7
  • 36
  • 61

0 Answers0