Iphone 当数组存储了另一个不同对象的数组时,如何将NSMutableArray保存到表中?

Iphone 当数组存储了另一个不同对象的数组时,如何将NSMutableArray保存到表中?,iphone,objective-c,uitableview,nsmutablearray,Iphone,Objective C,Uitableview,Nsmutablearray,我有一个数组,我想把它保存在UITable中,但它不可见,我的代码是 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

我有一个数组,我想把它保存在UITable中,但它不可见,我的代码是

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


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


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    NSString *cellValue = [myArrayNew objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    return cell;
}

这个数组有一些其他数组,而不是单个对象,

那么你应该用不同的代码

[myArrayNew objectAtIndex:indexPath.row]; 
将返回对象数组,而不是字符串

编辑:

可以使用分区表视图显示阵列的阵列

所以代码如下所示

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return [myArrayNew count];
}


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


// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    NSString *cellValue = [[myArrayNew objectAtIndex:section]objectAtIndex:indexPath.row];
    cell.textLabel.text = cellValue;
    return cell;
}

@Veer用这样的东西

NSArray *cellArray = [myArrayNew objectAtIndex:indexPath.row];
NSString *cellValue = [cellArray objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
或者类似的事情。如果您向我们展示myArrayNew中的内容类型,我们可以为您提供更多帮助


编辑:这只是一个示例,不是实际的答案。

您必须将值存储在一个数组中..以及可以指定给字符串的第二个数组对象..

您希望如何在UITableview中显示数组值的数组?一行中的所有3个元素,我希望如此确保您已经设置了表的数据源和委托。然后按照罗宾的指示去做。谢谢,如果Ray计数小于myArrayNew计数,此操作将崩溃。在这种情况下,索引可能会越界。是的,我知道,但这只是一个示例,而不是实际的解决方案。我在NSMutableArray中有两个值,但我想在一行中显示这两个值,然后在下一行中显示下两个值,明白了吗,先生?错误是“section”未声明,现在这个部分是什么?很抱歉将其更改为indexPath.sectionerror:在“.”之前应为“].”标记这是错误,当我将您的代码设置为NSString*cellValue=[[myArrayNew objectAtIndex.section]objectAtIndex:indexPath.row];NSString*cellValue=[[myArrayNew objectAtIndex:indexPath.section]objectAtIndex:indexPath.row];先生,我已经将其分配给了NSMutableArray,而不是NSString,但问题仍然是,我无法将NSMutableArray中的所有两个值显示在表的一行中