Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.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 CommittedItingStyle使我的应用程序崩溃_Ios_Swift_Tableview - Fatal编程技术网

Ios CommittedItingStyle使我的应用程序崩溃

Ios CommittedItingStyle使我的应用程序崩溃,ios,swift,tableview,Ios,Swift,Tableview,我的应用程序在执行“刷卡删除”功能时多次崩溃 reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plu

我的应用程序在执行“刷卡删除”功能时多次崩溃

reason: 'Invalid update: invalid number of rows in section 0.  
The number of rows contained in an existing section after the update
 (1) must be equal to the number of rows contained in that section 
before the update (1), plus or minus the number of rows inserted or     
deleted from that section (0 inserted, 1 deleted) and plus or minus the 
number of rows moved into or out of that section (0 moved in, 0 moved    
out).'
我在某个地方读到,这与numberOfRowsInSection中的行没有递减1有关,所以我创建了一个var deleted:Bool?在删除数据/行时进行更改。现在,我只需滑动并删除一次,我的应用程序在再次尝试后崩溃

以下是与此相关的代码:

[编辑]

我的数据源var myFavs:[MyFavorites]?是从CoreData生成的NSManagedObject子类。我忘了提到,当我从模拟器重新启动应用程序时,它成功地从coreData中删除

这是我的数据源代码,如果需要的话

extension MyFavourites {

@NSManaged var id: String?

}
我做错了什么


如果您使用myFavs作为数据源,则需要对其进行更新以备更改。例如,当您进行删除时,您需要从myFavs中删除相应的项。使用deletebool是不需要的,也不会有帮助。也许你应该发布更多的数据源委托方法。你需要更新myFavs。EG在这种情况下删除myFavo如果您阅读了错误消息,它会告诉您您做错了什么。它指出,更新后节中包含的行数需要与更新前的行数加上或减去更新数相匹配,因此换句话说,在对数据源进行任何更改后,您的numberOfRowsInSection计数需要始终等于其数据源。因此,如果删除一行,则必须更新数据源,使numberOfRowsInSection等于它的返回数据源。[你不需要一本书],只要更新你的阵列我做错了什么?错误消息完美地描述了这一点。。确保您的数据源也已更新。@youngbobby,您可能会错过更新数据源::self.arrayOfData.removeObjectAtIndexindexPath.row之类的内容
extension MyFavourites {

@NSManaged var id: String?

}