alllllllll 2013-05-08 02:03 采纳率: 0%
浏览 5048
已采纳

numberofRowsinSection 返回值

能不能将NSMutableArray返回成数字形式。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"number of rows in section: %@",[arrayofNombre objectAtIndex:section]);//it prints the right value
    return [arrayofNombre objectAtIndex:section];
}

代码一运行就崩溃。如果放进一个常数值,运行之后的结果也不对。求高手指点,谢谢。

  • 写回答

2条回答 默认 最新

  • ReyZhang 移动开发领域新星创作者 2013-05-08 06:21
    关注

    首先保证你的section 不会超过下标索引,不然会因超出索引而引发程序crash
    如果要返回NSInteger需要作类型转换

    return [[arrayofNombre objectAtIndex:section] intValue];
    

    但要保证你数组中的都是int类型,不然也会因为类型转换失败而导致程序crash.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制