2011-04-24 3 views
0

오류 받기 : -[NSCFNumber length]: unrecognized selector sent to instance 라인 [firstComponentText setString:[pickerArray objectAtIndex:row]];.간단한 NSCSF 번호 문제

-(void) viewDidLoad 
pickerArray = [[NSMutableArray alloc] initWithCapacity:700]; 
    for (float i = 0.0 ; i <= 1000.0 ; i = i + 2.5) 
     [pickerArray addObject:[NSNumber numberWithFloat:i]]; 

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component 
    { 
     if (thePickerView.tag==1)//weight 
     { 
      [firstComponentText setString:[pickerArray objectAtIndex:row]]; 
      weightLabel.text = firstComponentText; 
     } 
     } 

답변

1

pickerArrayNSNumber 개체가 있습니까? 그렇다면 NSString을 얻으려면 +[NSString stringWithFormat:] 또는 -[NSNumber stringValue]과 같은 방법을 사용해야합니다. 그런 경우에는

, 다음 중 하나를 수행하십시오

[firstComponentText setString:[[pickerArray objectAtIndex:row] stringValue]]; 

또는

[firstComponentText setString:[NSString stringWithFormat:@"%@", [pickerArray objectAtIndex:row]]]; 
+0

지금은 덕분에 잘 작동, 당신의 대답을 받아 들일 것입니다. –