2012-10-12 2 views
3

저는 XCode 초심자입니다. 따라서 XCode 설명서에 제공된 "Hello World"예제를 시도했습니다. 빠른 시작 가이드 : Tutorial: Using Xcode to Write “Hello, World!” for OS X.Xode 4.5 Hello World 예제가 작동하지 않습니다.

필자는 OS 10.8.2를 사용하여이 문서를 작성한 사람의 문서에서 XCode 4.5.1을 사용하고 있습니다. 나는 지침을 따랐다. 예제가 작동하지 않았습니다. 창문을 만들었지 만 "안녕하세요 세상"인쇄가 아닙니다. 관련 코드 :

- (void)drawRect:(NSRect)dirtyRect 
{ 
    // Drawing code here. 
    NSString *hello = @"Hello, World!"; 
    NSPoint point =NSMakePoint(15, 75); 

    NSMutableDictionary *font_attributes = [[NSMutableDictionary alloc] init]; 
    NSFont *font = [NSFont fontWithName:@"Futura-MediumItalic" size:42]; 
    [font_attributes setObject:font forKey:NSFontAttributeName]; 

    [hello drawAtPoint:point withAttributes:font_attributes]; 

    [font_attributes release]; 
} 

두 가지 주목할만한 것들이 있습니다. 이 코드의 마지막 줄에 오류가 있습니다 :

release is unavailable: not available in automatic reference counting mode 

그래서 나는 밖으로이 줄을 주석하고 프로그램을 실행했습니다. 창은 나타나지만 "Hello World"는 표시되지 않습니다.

"/Users/me/Library/ScriptingAdditions/YouHelper.osax/Contents/MacOS/YouHelper: no matching architecture in universal wrapper 
Hello: OpenScripting.framework - scripting addition "/Users/me/Library/ScriptingAdditions/YouHelper.osax" declares no loadable handlers." 

내가 뭔가 바보 같은 일을하고 있는가, 아니면 잘못된 예를 사용하고 있습니다 : 긴 메시지를 읽을 일부가 모든 출력에 등장!

답변

0

프로젝트를 보지 않고서 무엇이 잘못되었는지 찾아내는 것이 어렵습니다. 내 생각 엔 다음과 같습니다. IB에서 사용자 정의보기의 클래스를 지정하는 것을 잊었습니다 ("사용자 인터페이스 디자인"의 12 단계).

2

코드 끝 부분에서 [font_attributes release];을 제거해야합니다. release, retain, allocdealloc은 ARC (Automatic Reference Counting)에서 사용할 수 없습니다. 이것은 오류가 말하는 것입니다. 그리고 두 번째 오류에 대해서는 애플 스크립트와 애플 리케이션을위한 유사한 스크립팅 애드온을 언급하는 것을 제거해야합니다.