您知道删除Core Data中存储的所有条目的方法吗?我的架构应该保持不变; 我只是想把它重置为空白.
编辑
我希望以编程方式执行此操作,以便用户可以实际按下reset按钮.
在某些事件中,
我想删除一个uicollectionview中的所有单元格,并添加新单元格(将由于网络调用而填充)
我尝试使用deleteItemsAtIndexPaths.reloadSections,deleteSections/insertSections.
他们每个人都崩溃了我的应用程序.
以下是我的代码.
NSMutableArray* indexPathArray = [[NSMutableArray alloc] init];
for(int i=0; i < [self.jsonAlbumImageArray count]; ++i)
{
NSIndexPath* newPath = [NSIndexPath indexPathForRow:i inSection:0];
[indexPathArray addObject: newPath];
}
[self.jsonAlbumImageArray removeAllObjects];
if(indexPathArray.count > 0 )
{
[self.collectionView performBatchUpdates:^{
[self.collectionView deleteItemsAtIndexPaths:indexPathArray];
}
completion: nil];
}
// NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, 1)];
// NSIndexSet* indexSet = [NSIndexSet indexSetWithIndex:0];
// [self.collectionView reloadSections:indexSet];
[self get_IMAGE_LIST_FROM_SERVER];
Run Code Online (Sandbox Code Playgroud)