我正在運行一個非常基本的獲取請求,返回大約2000個對象。我使用NSFetchedResultsController與15.爲什麼我所有的NSManagedObjects都會立即出錯?
predicate= [NSPredicate predicateWithFormat:@"ANY tags.tagName==%@", currentTagObject.tagName];
[fetchRequest setPredicate:predicate];
NSSortDescriptor *sort= [[NSSortDescriptor alloc] initWithKey:@"createDate" ascending:NO selector:@selector(compare:)];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
[fetchRequest setFetchBatchSize:15];
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:appDelegate.managedObjectContext sectionNameKeyPath:@"createDay" cacheName:nil];
一個BATCHSIZE請求花費10秒以上雖然取。我已經啓用SQLite調試,以便我可以看到發生了什麼。我認爲這是獲取所有2000米的實體,只有15與實際值,然後因爲某些原因要通過每一個2000年的目標,並在斷層他們
在取,這些線路出現上千次:
2012-06-22 21:14:47.546 app[9227:707] CoreData: annotation: sql connection fetch time: 0.0107s
2012-06-22 21:14:47.551 app[9227:707] CoreData: annotation: total fetch execution time: 0.0171s for 15 rows.
2012-06-22 21:14:47.568 app[9227:707] CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZAUTHOREMAIL, t0.ZAUTHORNAME, t0.ZCREATEDATE, t0.ZISGLOBAL, t0.ZISLOCKED, t0.ZISNEW, t0.ZISPENDINGDELETE, t0.ZISPENDINGSYNC, t0.ZLASTUPDATED, t0.ZLOCALLYMODIFIEDDATE, t0.ZMETALASTUPDATED, t0.ZNOTEID, t0.ZNUMBEROFCHILDREN, t0.ZPARENTAUTHOREMAIL, t0.ZPARENTNOTEID, t0.ZROOTAUTHOREMAIL, t0.ZROOTNOTEID, t0.Z4PENDINGADDNOTES, t0.Z4PENDINGREMOVENOTES FROM ZMBNOTEOBJECT t0 WHERE t0.Z_PK IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ORDER BY t0.ZCREATEDATE DESC LIMIT 15
...thousands more lines exactly similar to the three above
我的表格每次只顯示5個單元格,所以我不知道爲什麼所有對象都立即出錯。什麼可能導致這個?爲什麼所有的對象都會立即出錯,甚至沒有我滾動我的桌子?它是否可以被訪問到某個地方,也許迭代?撥打NSArray *fetchedObjects = fetchedResultsController.fetchedObjects
是否會導致所有對象發生故障?
當你取出排序描述符時會發生什麼? –
NSFetchedResultsController獲取需要一個排序描述符。如果我試圖把它拿出來,我會崩潰 – Snowman
我不知道它是否是一種記憶的東西。通過查看select語句,看起來這個對象圖有孩子,並且比簡單的值對象稍微複雜一些。你有沒有嘗試設置includesSubentities爲NO並運行它? – jerrylroberts