Tag Archives: apple

Coredata Resource Links

 

Apple resource

Apple’s Core Data Programming Guide

Efficiently Importing Data

Apple guideline to import data

Cocoa is my Girlfriend

Super easy Fetching Core Data

Cocoa with Love

Core Data Line Fetch

Cocoa Dev Central

nice article with example structure and images

Import Data to CoreData Project

  • Create the model in XCode (it is essential do this first, because XCode uses a specific naming convention and adds several underlying tables to the actual data model.
  • Run the application in the Simulator and with the app running … go and copy the database (/users/library/Application Support/iPhone Simulator/User/Applications/ to some other location
  • Open up the database (I use SQLite Manager plugin in Firefox)
  • From here I import my data from a CSV file once I have updated all of my CSV column names to match the table names
  • Look at the CoreDataRecipies sample code for including a pre-populated database (code is in the Delegate.m file)
  • Import the database in your application and you should be good to go.
/**
 Returns the persistent store coordinator for the application.
 If the coordinator doesn't already exist, it is created and the application's store added to it.
 */
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
	
    if (persistentStoreCoordinator != nil) {
        return persistentStoreCoordinator;
    }
		
	NSString *storePath = [[self applicationDocumentsDirectory] stringByAppendingPathComponent:@"Recipes.sqlite"];
	/*
	 Set up the store.
	 For the sake of illustration, provide a pre-populated default store.
	 */
	NSFileManager *fileManager = [NSFileManager defaultManager];
	// If the expected store doesn't exist, copy the default store.
	if (![fileManager fileExistsAtPath:storePath]) {
		NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"Recipes" ofType:@"sqlite"];
		if (defaultStorePath) {
			[fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
		}
	}
	
	NSURL *storeUrl = [NSURL fileURLWithPath:storePath];
	
	NSError *error;
    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
    if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
		// Handle error
		NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
		exit(-1);  // Fail
    }    
		
    return persistentStoreCoordinator;
}

Xcode Color Themes


This is a small collection of my personal preference of color themes for xcode programming environment. For those who are looking for a dark theme. You can chose from one of the following color themes. I’m currently using teliaz theme, it has been tested and works very smoothly.

To get

teliaz theme

run the following code in Terminal:

mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/TeliazTheme.xccolortheme &> TeliazTheme.xccolortheme

To get

Ego theme

run the following code in Terminal:

mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/XCodeColorTheme.xccolortheme &> EgoTheme.xccolortheme

“EGO” uses the font “DejaVu Sans Mono” at 12pt. Some of you may know it as “Panic Sans” from Panic’s Coda (which is a repackaged version of it). You can grab the font over at dejavu-fonts.org. If you already have Code installed, feel free to swap in Panic Sans in place of DejaVu Sans Mono.

To get

Humane Theme

run the following code in Terminal:

mkdir -p ~/Library/Application\ Support/Xcode/Color\ Themes; cd ~/Library/Application\ Support/Xcode/Color\ Themes; curl http://teliaz.com/files/apple/Humane.xccolortheme &> Humane.xccolortheme

Now just restart Xcode, go to Preferences > Fonts & Colors, and select “one of these themes” from the color theme drop down. Hope you like it!! Happy coding…