在选择器视图iphone中选择行时出错

时间:2013-03-07 08:06:13

标签: iphone ios datepicker

我想用年显示选择器视图,我在我的userDC权限类中存储年数组但是我在日志消息上收到错误

   -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{

    userdc = [years objectAtIndex:row];
    NSLog(@"%d",userdc.user_year);


}

我的错误是这样的

-[__NSCFString user_year]: unrecognized selector sent to instance 0xaaa7220

2 个答案:

答案 0 :(得分:1)

如果你的user_year是字符串,那么

NSLog(@"%@",userdc.user_year);  

如果是整数那么

NSLog(@"%@",[NSString stringWithFormat:@"%d",userdc.user_year]);  

如果您的userdc是字典,则使用

NSLog(@"%@",[NSString stringWithFormat:@"%d",[userdc objectForKey:@"user_year"]); 

答案 1 :(得分:0)

yeppii ..我解决了我自己的问题:) :)通过这样做,thanx所有帮助我的人,欢呼

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    userdc=[[userDC alloc]init];
    userdc.user_year = [years objectAtIndex:row];

    NSLog(@"%@",userdc.user_year);

}