2010-02-07 4 views
2

나는 배포 할 작업 응용 프로그램을 가지고 있으며 NSLog 문을 정리하고 있습니다. "case"문에서 NSLog를 제거하면 NSArray가 "case"문 오류 내에서 앞에 선언 된 AND로 선언되지 않은 상태로 선언됩니다. 왜이게 될지 아무 생각 없어? 이것은 현재 NSLog를 제거하고있는 내 응용 프로그램의 모든 경우에 발생합니다. 예제 코드 섹션 아래에 나타납니다IPhone SDK에서 NSLog를 제거하면 NSArray가 선언되지 않습니다!

switch (chosenScene) 
{ 
    case 0: 
     //NSLog(@"group1"); // the following NSArray errors with "expected expression.." AND "..group1Secondsarray undeclared" 
     NSArray *group1SecondsArray = [NSArray arrayWithObjects: @"Dummy",@"1/15",@"1/30",@"1/30",@"1/60",@"1/125",@"1/250",nil]; 
     NSArray *group1FStopArray = [NSArray arrayWithObjects: @"Dummy",@"2.8",@"2.8",@"4",@"5.6",@"5.6",@"5.6",nil]; 
     NSString *group1SecondsText = [group1SecondsArray objectAtIndex:slider.value]; 
     calculatedSeconds.text = group1SecondsText; 
     NSString *group1FStopText = [group1FStopArray objectAtIndex:slider.value]; 
     calculatedFStop.text = group1FStopText; 
     [group1SecondsText release]; 
     [group1FStopText release];   
     break; 

답변

1

나는 공식적인 설명을 모르지만 당신이 다른 것을 다음 간단한 임무를 수행하거나 case 문에서 값을 반환하는 경우 다음 괄호 안에 넣어 필요 .

case 0: 
{ 
    NSArray* myArray=[NSArray arrayWithObjects:ob1, obj2,nil]; 
    ... 
} 
+0

대단한데, 내 문제를 해결했습니다. 답장을 보내 주셔서 감사합니다. –

+1

Maxwell Segal - 답변이 맞으면 옆에있는 체크 표시를 눌러 시스템에서 질문에 대한 답변을 얻고 Eyal Redler가 크레딧을받을 수 있도록하십시오. – TechZen

0

당신은 group1SecondsTextgroup1FStopText는, 그들이 배열에 있기 때문에 당신이 그들을 해제하는 경우가 무효가되며, 배열이 해제 될 때 부러 것, 일의 수를 유지해야 해제 할 필요는 없습니다 .

objectAtIndex:으로 NSArray의 개체에 액세스 할 때 유지 횟수가 증가하지 않고 배열에서 개체가 반환됩니다.

+0

이 질문에 신속하게 답변 해 주셔서 감사합니다. 건배. –

관련 문제