macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

addPersistentStoreWithType:configuration:URL:options:error:

データを保持するタイプを追加します
-(id)addPersistentStoreWithType:(NSString *)storeType:
             configuration:(NSString *)configuration:
             URL:(NSURL *)storeURL:
             options:(NSDictionary *)options:
             error:(NSError *)error:

解説

データを保持するタイプを追加します。
オブジェクトNSPersistentStoreCoordinatorを返します

【storeType】
●NSSQLiteStoreType   SQLiteタイプ
●  バイナリタイプ
●  XMLタイプ

返り値

( id )

NSPersistentStoreCoordinator

引数

( NSString * )storeType

保持するデータの形式

( NSString * )configuration
( NSURL * )storeURL

保存する場所

( NSDictionary * )options
( NSError * )error

クラス

NSPersistentStoreCoordinator

Instance Methods

使用可能

10.4

参照

-migratePersistentStore:toURL:options:withType:error:
-removePersistentStore:error:

例文

NSURL *url;
url = [NSURL fileURLWithPath: [applicationSupportFolder stringByAppendingPathComponent: @"CoreData001.xml"]];

if ([coordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]){
        managedObjectContext = [[NSManagedObjectContext alloc] init];
        [managedObjectContext setPersistentStoreCoordinator: coordinator];
    }