2010-04-29 9 views
6

아래 코드에서 '^'는 무엇을 의미합니까?

@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 

=== 내가 검색하고 검색 한 - 그것은 메모리에 특정 기준의 일종인가?Objective-C의 '^'는 무엇입니까

답변

9

위로 읽으십시오. here. 이것은 기본적으로 람다 형식 인 "블록 객체"이며 Snow Leopard의 GCD (Grand Central Dispatch)를 지원하기 위해 도입되었습니다.

3

Apple에서 만든 C의 확장자 인 block (a.k.a. closure)입니다.

6

작은 :

a^b 

는 XOR B를 의미 다음 '^'문자 (캐럿이나 곡절 문자) 이진 연산자로서 사용될 다른 의미를 갖는다. XOR (일명 배타적 OR)은 a 또는 b에 1이 있지만 둘 다 아닌 모든 비트 위치에 결과가 1 인 이진 산술 연산입니다.