Ios 从tableView:numberOfRowsInSection返回整数可以吗?

Ios 从tableView:numberOfRowsInSection返回整数可以吗?,ios,uitableview,casting,Ios,Uitableview,Casting,我正在开发一个简单的表视图iOS应用程序,我想为NSMutableDictionary中的每个条目显示一个单元格。以下是我当前使用的代码: - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [myDict count]; } 据我所知,N

我正在开发一个简单的表视图iOS应用程序,我想为NSMutableDictionary中的每个条目显示一个单元格。以下是我当前使用的代码:

   - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{
    // Return the number of rows in the section.
    return [myDict count];
}

据我所知,NSMutableDictionary的count方法返回一个整数。使用上述代码时是否会有任何问题需要注意?

不会有任何问题,因为count始终是0或更大的数字,它可以返回无符号整数。

严格来说,[myDict count]超过NSIntegerMin/LONG\u MAX时可能会有问题,但实际上,正如你所说,这不会成为一个问题。我不明白的是,为什么numberOfRowsInSection一开始不使用整数(即,它什么时候会返回负数?)@NicholasHarlen据我所知,没有理由返回负数,我的猜测是,苹果把它做成了一个NSInteger,因为当时他们认为返回一个负数在未来的实现中可能会有意义。