删除对象的多对多关系非常慢,如何让它更快?

时间:2014-04-04 07:05:47

标签: ios performance core-data many-to-many

使用https://github.com/magicalpanda/MagicalRecord

的CoreData操作

我有2个表,

  1. 播放列表,列:播放列表名称
  2. 曲目,专栏:专辑,艺术家,创作时...... ......
  3. 播放列表和曲目是多对多关系,删除规则是Nullify。

    有两种情况:

    1. NSFetchedResultsController for [self MR_fetchAllSortedBy:@"CreateTime" ascending:NO withPredicate:nil groupBy:nil delegate:self inContext:context]; ...... Tracks *obj = [self.fetchedResultsController objectAtIndexPath:indexPath]; [obj MR_deleteEntity]; [[obj managedObjectContext] MR_saveToPersistentStoreAndWait];
    2. 快速删除跟踪对象。

      1. [self MR_fetchAllGroupedBy:@"Album" withPredicate:nil sortedBy:nil ascending:NO delegate:self inContext:context]; ......

        的NSFetchedResultsController

        segue push

      2. id<NSFetchedResultsSectionInfo> sectionInfo = [[self.fetchedResultsController sections] objectAtIndex:indexPath.row]; AlbumTracksViewController *albumTracksvc = segue.destinationViewController; albumTracksvc.tracks =[NSMutableArray arrayWithArray:[sectionInfo objects]]; albumTracksvc.title = [sectionInfo name];

        In AlbumTracksViewController:
        

        Tracks *obj = [self.tracks objectAtIndexPath:indexPath]; [obj MR_deleteEntity]; [[obj managedObjectContext] MR_saveToPersistentStoreAndWait];

        the delete Track Object very slow.
        

        我该怎么做才能解决删除缓慢的问题?

0 个答案:

没有答案