Iphone numberofRowsinSection是否可以返回NSMutableArray的值?

Iphone numberofRowsinSection是否可以返回NSMutableArray的值?,iphone,ios,uitableview,Iphone,Ios,Uitableview,是否可以将NSMutableArray的值(而不是计数)作为节中的行数返回 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog(@"number of rows in section: %@",[arrayofNombre objectAtIndex:section]);//it prints the right value return

是否可以将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)时,应用程序运行了,但没有给出预期的结果。 我肯定错过了什么。
谢谢您的帮助。

没有。您将返回一个NSInteger。如果选择,则需要显式声明一个属性来保存该值

似乎您正在返回一个NSNumber,而该方法需要一个NSInteger。您应该按如下方式转换NSNumber

- (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] intValue];
}

如果阵列包含NSNumber的实例,则需要将对象转换为NSInteger:

return [[arrayofNombre objectAtIndex:section] integerValue];

您如何检测问题:D!它解决了我的问题:)。非常感谢,并接受了。不客气,考虑到NSArray只能容纳NSNumber,这只是一个猜测而已!:)