2011-07-29 3 views
-1
enter code hereIn my Application I am using Sqlite as an externel data base. So, Please Reply.I am using Xcode finding defficult to communicate to the sqlite file and Managed Object Model.. 


    enter code here 



- (NSPersistentStoreCoordinator *)persistentStoreCoordinator 
{ 
    if (__persistentStoreCoordinator != nil) 
    { 
     return __persistentStoreCoordinator; 
    } 

    NSURL *storeURL=[[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreDataBountyHunter.sqlite"]; 

    NSError *error = nil; 
    __persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; 
    if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) 
    { 

    //  
     Typical reasons for an error here include: 
     * The persistent store is not accessible; 
     * The schema for the persistent store is incompatible with current managed object model. 


     NSLog(@"Unresolved error %@, %@", error, [error userInfo]); 
     abort(); 
    }  

    return __persistentStoreCoordinator; 
} 
+1

これは問題ではありません。あなたはどんな問題を抱えていますか?何を試しましたか? –

答えて

1

独自のストアを実装していない限り、コアデータは外部SQLiteデータベースで使用することはできません。事前定義されたスキーマを持つ外部データベースが必要な場合は、コアデータをソリューションに収めないでください。代わりに、標準C APIを使用してSQLiteデータベースと対話してください。

+0

Sir、あなたは正しいですが、ここでは、 "コアデータはSqlの詳細を調べたくない場合、Sqliteを処理するのに非常に便利です"というサンプルアプリケーションがあります。あなたがしたい。そこで、私はフェッチ要求とストアコーディネーターのコードを提示しています。 –

+0

すべての事がこの部分の代わりにうまくいっています。私はエラーがあり、中止を呼びます。 –

関連する問題