Skip to content

Repository files navigation

DCTCoreDataStack

DCTCoreDataStack is intended for non-document based apps, and sets up the whole Core Data structure such that after initializing, the managedObjectContext property is ready for use.

DCTCoreDataStack provides the following features:

  1. An encapsulation of the complete Core Data stack of NSManagedObjectContext, NSPersistentStoreCoordinator, NSPersistentStore, and NSManagedObjectModel
  2. On supporting OS’s, writing to disk is performed on a background thread, by using a parent context. Saving the main context automatically triggers saving the parent context asynchronously
  3. -[NSManagedObjectContext dct_saveWithCompletionHandler:] method can be used to be notified when saving to disk finishes, asynchronously if possible
  4. Allows you to resolve errors when loading the persistent store by setting the didResolvePersistentStoreErrorHandler block and handling the error
  5. On iOS, the app entering the background, or terminating, automatically triggers a save if needed. You can be notified of such saves by setting the automaticSaveCompletionHandler block
  6. On iOS, when saving on a background thread, the stack protects against termination/suspension by declaring the save as a background task
  7. Providing YES for DCTCoreDataStackExcludeFromBackupStoreOption in the storeOptions will exclude the persistent store from being backed up

Documentation

Full documentation is here.

Thanks

Thanks to Mike Abdullah for persisting on making this better (via continuously pestering me) and writing a lot of the documentation.

License

Copyright © 2012 Daniel Tull. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THISSOFTWARE IS PROVIDED BY THECOPYRIGHTHOLDERSANDCONTRIBUTORS “AS IS” ANDANYEXPRESS OR IMPLIEDWARRANTIES, INCLUDING, BUTNOTLIMITED TO, THEIMPLIEDWARRANTIES OF MERCHANTABILITYANDFITNESSFOR A PARTICULARPURPOSEAREDISCLAIMED. IN NO EVENTSHALLTHECOPYRIGHTOWNER OR CONTRIBUTORS BE LIABLEFORANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIALDAMAGES (INCLUDING, BUTNOTLIMITED TO, PROCUREMENT OF SUBSTITUTEGOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVERCAUSEDAND ON ANYTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICTLIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANYWAYOUT OF THEUSE OF THISSOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCHDAMAGE.

About

Easily sets up a read to use core data stack

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors