Tag Archives: cocoa

Cocoapods after El Capitan installation

After updating to El Capitan I stumbled upon an serious issue. I couldn’t update pods on my projects. Pod command could not be found. I had find a way to re-install cocoapods.

Simple solution. Go to terminal and run the following command

sudo gem install -n /usr/local/bin cocoapods

Original command gem install
sudo gem install cocoapods was not working cause of writing permissions.

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;