2
我是一名經驗豐富的iOS開發人員,試圖製作我的第一款Mac應用程序。我想使用Core數據將數據存儲在我的應用程序中。在我的iOS應用程序,我通常都被用作數據存儲的初始狀態的預創建的SQLite文件,以及移動到位的首次應用程序運行時,像這樣:如何在Mac應用程序中設置初始Core Data存儲?
NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"Datafile.sqlite"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:storePath]) {
NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"Datafile-DefaultData" ofType:@"sqlite"];
if (defaultStorePath) {
[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
}
}
我想在mac應用中做類似的事情,除了將數據放在~/Library/Application Support/MyApp
目錄中。我似乎無法弄清楚如何去做。任何指針?
所以,如何做到這一點,它應該如你所願。我是否將其從'〜/ Library/Application'改爲其他? – Jason