2014-09-03 5 views
-2

'이름'에 배열 이름이 있습니다. 사용자가 표 셀을 탭하면 경고를 표시하려고합니다. 사용자가 첫 번째 셀을 터치하면 [이름 objectatindex : 0]이 경고보기의 메시지 여야합니다. 여기 내가 한 일이 있습니다경고보기에 변수를 전달할 수 없습니다.

UIAlertView *okAlert = [[UIAlertView alloc] initWithTitle:@"ok" message:@"You have just tapped [names objectatindex:0]" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; 

    okAlert.tag=0; 


    [okAlert performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:NO]; 

메시지에는 이름이 표시되지 않습니다. 나는 그 문제를 알아낼 수 없었다. 이걸 좀 도와 주실 래요?

미리 감사드립니다.

+1

읽기. – rmaddy

답변

3

이 시도 :

UIAlertView *okAlert = [[UIAlertView alloc] initWithTitle:@"OK" 
                message:[NSString stringWithFormat:@"You have just tapped %@.", [names objectAtIndex:0]] 
               delegate:self 
             cancelButtonTitle:@"No" 
             otherButtonTitles:@"Yes", nil]; 
0
message:@"You have just tapped [names objectatindex:0]" 

당신은 문자열 상수 내부에 그 코드를 숨긴. 이제는 문자 일뿐입니다.

시도 :``는 NSString stringWithFormat에 대한

UIAlertView *okAlert = [[UIAlertView alloc] initWithTitle:@"ok" 
    message:[@"You have just tapped " stringByAppendingString:names.firstObject] 
    delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; 
관련 문제