2011-11-11 2 views
0

오류가 예상되는 식별자 또는 '('.)와 함께 어떤 이유로 자동 줄 바꿈을 맨 위에 표시했습니다. 이것이 무엇을 의미하는지 모르겠습니다. 나는 그것을 고치기 위해 고심하고있다. 나는 컴퓨터 과학 전공으로서, 수업을 시작하기 전에 steve kochan의 책에서 객관적인 C를 가르치려고 노력하고있다. 어떤 도움도 좋을 것이다! (코드는 아래에 게시 됨)예상되는 식별자 또는 ''(

int main (int argc, char * argv[]); 
{ 

    autoreleasepool; 
    { 
     Fraction *myFraction; 

     //Create an instance of a Fraction 

     myFraction = [Fraction alloc]; 
     myFraction = [myFraction init]; 

     // Set fraction to 1/3 

     [myFraction setNumerator: 1]; 
     [myFraction setDenominator: 3]; 

     // Display the fraction using the print method 
     NSLog (" The value of myFraction is:"); 
     [myFraction print]; 
    } 
    return 0; 
} 

답변

3

난 당신이 하나 개의 문자를 놓쳤다 생각합니다.

@autoreleasepool {를 사용해보십시오.

,

int main (int argc, char * argv[]); { 

이어야

int main (int argc, char * argv[]) { 

autoreleasepool; 

을해야한다 (A @를 추가하고 세미콜론을 제거) 당신이 당신의 세미콜론을 게시

3

다시 생각을

,
@autoreleasepool 
+0

했다 바보 세미콜론 것을해야합니다! 나는 그곳에 있어야한다고 생각하지는 않았지만 나는 그 시점에서 일을 시도하고 있었다. 나는 거기에 있어야한다고 생각했다. 정말 고맙습니다! 나는 한동안 저주를 당했다! – StormsEdge

+0

당신은 환영합니다 :). 그러나 이것이 당신의 질문에 대답한다면 : 왼쪽에있는 체크를 사용하여이 대답을 "수락 된 대답"으로 표시하십시오. – vstrien

0

또한

NSLog (" The value of myFraction is:"); 

그것은

NSLog (@" The value of myFraction is:"); 
0
int main(int argc, char *argv[]) { 
    @autoreleasepool { 
     Fraction *myFraction; 

     //Create an instance of a Fraction 
     myFraction = [[Fraction alloc] init]; 

     // Set fraction to 1/3 
     [myFraction setNumerator:1]; 
     [myFraction setDenominator:3]; 

     // Display the fraction using the print method 
     NSLog(@"The value of myFraction is:"); 
     [myFraction print]; 

     [myFraction release]; // you will read about this later in your book ;) 
    } 
    return 0; 
} 
+0

ARC를 추가 한 이후 더 이상 개체를 해제 할 필요가 없습니다. haha – StormsEdge

관련 문제