I came across this in some example code:
- (IBAction) startPlayLowNote:(id)sender {
UInt32 noteNum = kLowNote;
UInt32 onVelocity = 127;
UInt32 noteCommand = kMIDIMessage_NoteOn << 4 | 0;
OSStatus result = noErr;
require_noerr (result = MusicDeviceMIDIEvent (self.samplerUnit, noteCommand, noteNum, onVelocity, 0), logTheError);
logTheError:
if (result != noErr) NSLog (@"Unable to start playing the low note. Error code: %d '%.4s'\n", (int) result, (const char *)&result);
}
What does “logTheError:” do? What is this syntax called? Where can I go for more information on it?
logtheError:is a label. Therequire_noerrmacro has agotoin it that will jump to a specified label in the case of an error. Here’s a simplified and expanded goto/label example without any funny business or macros:It’s C syntax originally. You can learn more in the C standard, section 6.8.1 Labeled statements.