CoreData-Cappuccino is a project mainly written in Objective-J, it's free.
This project is no longer under active development. Here for historical reasons.
Just copy the CoreData folder to your Project Frameworks folder and import the Framework in you Application Delegate file.
#import <CoreData/CoreData.j>
The Data Model file must be stored in your Project Resources
folder.
CoreData:
var model = [CPManagedObjectModel modelWithModelNamed:@"YourModelFile.xcdatamodel" bundle:nil];
EOModel:
var model = [CPManagedObjectModel modelWithModelNamed:@"YourModelFile.eomodeld" bundle:nil];
This instruction is not necessary if you use the latest Xcode Cappuccino Templates.
Your .xcdatamodel file location should be the Project Resources folder
Open a Terminal and switch to the Project Resources folder.
Compile the .xcdatamodel file with momc
/Developer/usr/bin/momc source.xcdatamodel target.cxcdatamodel
The compiled file suffix is .cxcdatamodel
Transform the binary formatted file into xml
(I work on a binary parser for Cappuccino but until I am finish this step is necessary)
plutil -convert xml1 target.cxcdatamodel
Every store depends on two parts:
Configuration Dictionary:
Key: CPWebDAVStoreConfigurationKeyBaseURL
Object: is the base URL for exp.: @"http://localhost:8080"
Key: CPWebDAVStoreConfigurationKeyFilePath
Object: file path/name.suffix exp.: @"addressbook.json"
Key: CPWebDAVStoreConfigurationKeyFileFormat
Object: The format of your store exp.:
CPCoreDataSerializationJSONFormat || CPCoreDataSerializationXMLFormat || CPCoreDataSerialization280NPLISTFormat
Implementation: You can see a demo for this in the Addressbook Example ABContextController.j Class.
- (id) initWithContext
{
if(self = [super init])
{
//load your model file
var model = [CPManagedObjectModel modelWithModelNamed:@"AddressBook.xcdatamodel" bundle:nil];
var coordinator = [[CPPersistentStoreCoordinator alloc]
initWithManagedObjectModel:model
storeType:[CPWebDAVStoreType class]
storeConfiguration:[ABContextController webDAVConfig]];
//init the context with the coordinator
context = [[CPManagedObjectContext alloc] initWithPersistantStoreCoordinator: coordinator];
[context setAutoSaveChanges:YES];
}
return self;
}
+ (CPDictionary) webDAVConfig
{
var result = [[CPMutableDictionary alloc] init];
[result setObject:@"http://localhost:8080" forKey:CPWebDAVStoreConfigurationKeyBaseURL];
[result setObject:@"addressbook.json" forKey:CPWebDAVStoreConfigurationKeyFilePath];
[result setObject:CPCoreDataSerializationJSONFormat forKey:CPWebDAVStoreConfigurationKeyFileFormat];
return result
}
Using the Addressbook Application Example:
If you have no WebDAV Server running I recommend jack-dav for Testing.
The Example work also without a server, in this case the data will store in memory
Notes:
Currently accessing a user/password protected webdav is not supported, If you know how, please write me a mail.
!!! Currently not up-to-date with the latest implementation, I work on a update for both client and server side !!!