Tableview - NSMutableDictionary - currow获取整数值?苹果手机

时间:2011-06-01 13:14:18

标签: iphone objective-c uitableview nsmutabledictionary

如何将ID的值转换为Integer。见下文:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NSMutableDictionary *curRow = [myData objectAtIndex:indexPath.row];

    NSLog(@"Cell Click  %@ %@  -  %@",[curRow objectForKey:@"Name"], [curRow objectForKey:@"ID"], [curRow objectForKey:@"DOB"]);

    UserID= [curRow [objectForKey:@"ID" intValue]  ;  <<<< This doesnt work?

2 个答案:

答案 0 :(得分:2)

如果ID在字典中,则可以使用

字符串
UserID = [[curRow objectForKey:@"ID"] intValue];

答案 1 :(得分:0)

你的语法错误。

UserID= [curRow [objectForKey:@"ID" intValue]  ;  <<<< This doesnt work?

使用以下

UserID= [[curRow objectForKey:@"ID"] intValue]  ;  <<<< This will work?