天兒真好所有當觸發下載StackMob初始數據到CoreData應用
我工作的一個CoreData驅動應用程序,它與空CoreData店,我從一個應用填充開始。
我有一個UITableView的子類提取&提供我的數據,因爲我希望它,但我有點困惑時,我應該最好從StackMob獲取最初的數據。當我在applicationDidFinishLaunching中填充我的CoreData存儲(從小plist文件&僅用於測試視圖)時,我的應用程序花費了很長時間顯示默認屏幕&我期望從Web上獲取實際數據的時間會更長。我在考慮我的UITableView子類改變這種方法...
- (NSFetchedResultsController *)frc
{
if (_frc) return _frc;
...
return _frc;
}
到...
- (NSFetchedResultsController *)frc
{
if (_frc) return _frc;
...
if ([[_frc fetchedObjects] count] == 0) {
// Spawn NSOperation to get initial data from StackMob.
// & use it to populate my CoreData store.
}
return _frc;
}
在這種情況下,我做的NSOperation的子類,我可以重新用於後續的數據更新。 我正在檢查[[_frc fetchedObjects] count] == 0
,因爲我正在從實體中提取所有數據。
是一種很好的方法嗎?如果不是更好的方法?
我希望能提供一些用戶體驗,就像我在某些應用程序中看到的一樣,我使用的項目出現在「主頁」屏幕上,因爲它被下載到CoreData商店中添加到&。
乾杯& TIA,佩德羅:)
您是否按照真棒核心數據教程之一這將引導您通過使用Xcode定義CoreData架構(如http://cocoadevcentral.com/articles/000085.php)的端到端場景,或者您已經交付了您的數據結構並且只是在代碼界面上工作? – bmike
我的代碼基於Apple示例和一些在線教程(包括Marcus Zarra),非常接近以下ScanPlayGames提供的內容。我編輯了這個問題,使我真正要求更清楚。 – Pedro