我的程序使用Coredata(SQLite),NSPersistentDocument,NSTableView和(實體)NSArrayController。我希望主線程中的NSTableView的列綁定到實體NSArrayController,我已經在輔助線程中填充了這些列。NSTableView列可以在輔助線程中綁定到coredata實體NSArrayController嗎?
問題1:有可能嗎?不幸的是沒有在我的情況下工作(同時通過IB作品在同一線程中做所有事情)
目標是什麼:讓「fetch's」(大文檔平均值爲2-4秒完成)抓取時,我可以在UI上顯示進度指示器。
問題2:當實體nsarraycontroller正在安排其數據,獲取等等時,是否有任何其他推薦方法顯示進度指示符?
在此先感謝。 路易斯
// ------- ABCoredataController.h
@interface ABCoredataController : NSObject {
:
NSArrayController *ivArrayController;
}
@property (nonatomic, assign) NSArrayController *arrayController;
// ------- ABCoredataController.m
// This piece executes in Main thread...
- (void) init {
ivArrayController = [[NSArrayController alloc] init];
:
// Following is later executed in the Secondary Thread
- (void) secondaryThreadRun:(id)param {
:
// prepare everything to access coredata from a secondary thread...
[self setSecondaryThreadMOC: [[[NSManagedObjectContext alloc]init] autorelease] ];
[[self secondaryThreadMOC] setPersistentStoreCoordinator:[self mainThreadPSC]];
// prepare the (entity) array controller
[[self arrayController] setAvoidsEmptySelection:YES];
[[self arrayController] setPreservesSelection:YES];
[[self arrayController] setSelectsInsertedObjects:YES];
[[self arrayController] setClearsFilterPredicateOnInsertion:YES];
[[self arrayController] setAutomaticallyPreparesContent:YES];
[[self arrayController] setAutomaticallyRearrangesObjects:YES];
[[self arrayController] setAlwaysUsesMultipleValuesMarker:NO];
[[self arrayController] setUsesLazyFetching:NO];
[[self arrayController] setEditable:YES];
[[self arrayController] setEntityName:@"Transaction"];
// bind arrayController to the managedObjectContext
[[self arrayController] setManagedObjectContext:[self secondaryThreadMOC]];
[[self arrayController] setFilterPredicate:[self predicate]];
:
然後在那裏我控制我的廈門國際銀行和所有的UI類裏面...
3210