开发者

Solve Simple NSCSF Number Problem

Getting the error: -[NSCFNumber length]: unrecognized selector sent to instance at line [firstComponentText setString:[pickerArray objectAtIndex:row]];.

-(void) viewDidLoad
pickerArray = [[NSMutableArray alloc] initWithCapacity:700];
    for ( float i = 0.0 ; i <= 1000.0 ; i = i + 2.5)
        [pickerArr开发者_开发百科ay 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;
        }
        }


Does your pickerArray contain NSNumber objects? If so, to get an NSString, you'll need to use a method like +[NSString stringWithFormat:] or -[NSNumber stringValue].

If that's the case, try either of the following:

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

or

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜