Remove Core Data from an Xcode project

Asked

Viewed 316 times

1

I started an app development using Core Data in the course of the development of the project I have been observing that the Core Data is not the best for the app.

Within this scenario, I would like to know how I do to remove Core Data completely of my application and continue the development of the same without it.

1 answer

1

Since you didn’t specify whether it’s Swift or Objective-C, I’ll guess it’s Objective-C. But the process on Swift is similar.

  1. Select the project on Project Navigator -> Build Phases and in Link Binary With Libraries remove the CoreData.framework
  2. (Skip this step if you are Swift) Search for the . pch file of your project. Usually the default is: [Name of your project]-Prefix.pch. Remove the line from #import <CoreData/CoreData.h>
  3. Delete any file *.Model
  4. In the AppDelegate.h delete the following properties and methods (On Swift are the lazy var eponymous):

    • @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext; @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel; @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
    • - (void)saveContext;
      - (NSURL *)applicationDocumentsDirectory;
  5. (Skip this step if you are Swift) No AppDelegate.m remove the @synthesize of the properties you have just removed:

    • @synthesize managedObjectContext = _managedObjectContext; @synthesize managedObjectModel = _managedObjectModel; @synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
  6. Still in the AppDelegate.m delete the following methods:

    • saveContext managedObjectContext managedObjectModel persistentStoreCoordinator applicationDocumentsDirectory
  7. And finally, still in AppDelegate.m, within the method applicationWillTerminate remove the call from the method [self saveContext]

Okay, you got rid of Coredata!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.