相关疑难解决方法(0)

删除/重置核心数据中的所有条目?

您知道删除Core Data中存储的所有条目的方法吗?我的架构应该保持不变; 我只是想把它重置为空白.


编辑

我希望以编程方式执行此操作,以便用户可以实际按下reset按钮.

cocoa cocoa-touch core-data nsmanagedobject ios

229
推荐指数
13
解决办法
15万
查看次数

如何删除所有项目并向UICollectionView添加新项目?

在某些事件中,

我想删除一个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)

iphone ios uicollectionview

6
推荐指数
2
解决办法
2万
查看次数