What is "^" in Objective-C

What does the “^” mean in the code below?

@implementation AppController - (IBAction) loadComposition:(id)sender { void (^handler)(NSInteger); NSOpenPanel *panel = [NSOpenPanel openPanel]; [panel setAllowedFileTypes:[NSArray arrayWithObjects: @"qtz", nil]]; handler = ^(NSInteger result) { if (result == NSFileHandlingPanelOKButton) { NSString *filePath = [[[panel URLs] objectAtIndex:0] path]; if (![qcView loadCompositionFromFile:filePath]) { NSLog(@"Could not load composition"); } } }; [panel beginSheetModalForWindow:qcWindow completionHandler:handler]; } @end 

=== I searched and searched - is this some kind of specific memory reference?

+6
objective-c
source share
4 answers

Read on it here . This is a “Block Object,” which is basically a lambda form, and was introduced to support the Snow Leopard GCD (Grand Central Dispatch).

+9
source share

Just a little aside: the symbol "^" (carriage or stroke symbol) has a different meaning when used as a binary operator:

 a ^ b 

means XOR b. XOR (aka exclusive OR) is a binary arithmetic operation in which the result has 1 at any bit position, where either a or b has 1, but not both.

+6
source share

This is block (closing aka), a C extension created by Apple.

+3
source share

This block is probably for use with Grand Central Dispatch .

+2
source share

All Articles