lantianyiming 2013-08-15 03:33 采纳率: 0%
浏览 2046
已采纳

使用 NSMutableArray充填UItableview

使用数组充填UItableview ,需要在数组的cell中匹配对象。

数组如下:

(
        (
                {
            cost = 160;
            height = 1;
            room_number = 1;
            square_size = 1;
            title = "TIMBER BLINDS";
            width = 1;
        }
    ),
        (
                {
            cost = 170;
            height = 1;
            room_number = 2;
            square_size = 1;
            title = "ROMAN BLINDS";
            width = 1;
        }
    )

问题:如何将正确的标题匹配到cell中,配对条件是array的room_number。

  • 写回答

1条回答 默认 最新

  • redCoral_ 2013-08-15 07:41
    关注

    你用数组的数组,其中包含了dictionary,因此第一步需要用indexPath.row从数组中获取对象。获取的对象也是一个数组,再用objectAtIndex从中获取字典对象。这样你就可以获取字典也就可以访问键值了。

    NSMutableArray *fetchedArray= [yourArray objectAtIndex:indexPath.row];
    NSDictionary *fetchedDictionary = [fetchedArray objectAtIndex:0];
    
    NSNumber *roomNumber= [fetchedDictionary valueForKey:@"room_number"];
    if([roomNumber intValue] == indexPath.row) {
        [cell setTextLabel:[fetchedDictionary valueForKey:@"title"]];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?