Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 检测NSMutableArray的长度_Ios_Objective C_Cocoa Touch_Uitableview_Nsmutablearray - Fatal编程技术网

Ios 检测NSMutableArray的长度

Ios 检测NSMutableArray的长度,ios,objective-c,cocoa-touch,uitableview,nsmutablearray,Ios,Objective C,Cocoa Touch,Uitableview,Nsmutablearray,我对如何解决这个问题有点目瞪口呆,我的搜索也没有进展 我有以下代码: - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { [_testTableView beginUpdates]; NSDictionary *dictionary = [_array00 objectAtIn

我对如何解决这个问题有点目瞪口呆,我的搜索也没有进展

我有以下代码:

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
  [_testTableView beginUpdates];

  NSDictionary *dictionary = [_array00 objectAtIndex:fromIndexPath.section];
  NSMutableArray *array = [dictionary objectForKey:@"data"];

  NSString *itemToMove = [array objectAtIndex:fromIndexPath.row];
  [array removeObjectAtIndex:fromIndexPath.row];
  [array insertObject:itemToMove atIndex:toIndexPath.row];

  [_testTableView moveSection:fromIndexPath.section toSection:toIndexPath.section];

    //I need to know what size my array is at this point. _array00 is a NSMutableArray made up from 2 other NSMutableArrays.

  [_testTableView endUpdates];
}

因此,我正在制作一个应用程序,允许您在
UITableViewController
中将
单元格
从一个
重新排序到另一个组

我不确定我是否会说对这个词,但我希望它有意义

NSMutableArray
的大小改变时,我需要检查运行时,因为我将
行从一个
节移动到另一个
节。

有人能帮我一下吗:-)

您正试图将itemToMove添加到同一分区中。。将itemToMove添加到toindexpath.section数组中

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
[_testTableView beginUpdates];

NSDictionary *dictionary = [_array00 objectAtIndex:fromIndexPath.section];
NSMutableArray *array = [dictionary objectForKey:@"data"];

NSString *itemToMove = [array objectAtIndex:fromIndexPath.row];
  [array removeObjectAtIndex:fromIndexPath.row];

NSDictionary *toDictionary = [_array00 objectAtIndex:toIndexPath.section];
NSMutableArray *toArray = [toDictionary objectForKey:@"data"];
  [toArray insertObject:itemToMove atIndex:toIndexPath.row];

[_testTableView moveSection:fromIndexPath.section toSection:toIndexPath.section];

//This is where I assume my missing code has to go

  [_testTableView endUpdates];
}

我希望这可以解决您的问题。

何时向可变数组添加或删除项目?你不能控制吗?当项目被更改时,你能更新你的表格吗?是的,@AaronBrager的意思是,你怎么能不知道,因为你是做出更改的人。嗯,好吧-这不是我不知道,我更想知道的是,从控制器的角度来理解它,然后我想知道它在应用程序流程方面是否处于正确的位置。-我将更新注释:-)我使用分组布局,因此有两个部分-您给出的答案仍然不正确,但正在尝试找出原因。