简体   繁体   English

核心数据中的对象共享相同的信息,并且不会完全删除

[英]Objects in core data share the same information and don't fully delete

I have an app that uses core data to store two UITables of information. 我有一个使用核心数据存储两个UITables信息的应用程序。 When the a collection row is tapped it shows a table that has pictures. 点按收集行时,将显示一个包含图片的表格。 The option to add a picture or collection is indicated with the +. 添加图片或图片集的选项用+表示。 When ever a new picture object is inserted [collection addPhotoObject:photo]; 每当插入新图片对象时[collection addPhotoObject:photo]; and you navigate to another collection it has the same row there. 然后您导航到另一个具有相同行的集合。 Even when all the collections are deleted and a new one is added, it has the same info as the old one(s). 即使删除了所有集合并添加了新集合,其信息也与旧集合相同。 How can this be prevented? 如何预防?

Has this been encountered before? 以前是否遇到过? Any suggestions? 有什么建议么?

Thanks in advance! 提前致谢!

If anyone comes upon this in the future I hope this helps answer their question. 如果将来有人遇到这个问题,我希望这有助于回答他们的问题。

After several trials I found my problem. 经过几次试验,我发现了我的问题。 I was not populating my data correctly. 我没有正确填充数据。 All I had to do was return [collection.indexCard count]; 我要做的就是return [collection.indexCard count]; in -tableView:tableView numberOfRowsInSection:section . in -tableView:tableView numberOfRowsInSection:section I also had to make sure that whenever I added or deleted an object I use some form of [self.tableview reloadData] . 我还必须确保无论何时添加或删除对象,我都使用[self.tableview reloadData]某种形式。

PS If a change is made (and with any core data) delete the app from the simulator to reset everything. PS如果进行了更改(以及任何核心数据),请从模拟器中删除该应用程序以重置所有内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM