Welcome to the documentation for the APCoreData framework!

APCoreData is a powerful data persistence library built on top of Apple’s Core Data framework. It provides developers with additional functionalities and simplifies common tasks when working with Core Data.


  1. Open your project in Xcode.
  2. Navigate to your project’s target settings.
  3. Select “General” and scroll down to find the “Frameworks, Libraries, and Embedded Content” section.
  4. Click on the “+” button.
  5. Search for “APCoreData” and select it from the results.
  6. Choose the appropriate version and click “Add” to add the framework to your project.
  7. Import APCoreData in your code using:
  8. import APCoreData

Basic Usage

The following example illustrates how to utilize APCoreData for basic data operations.

import APCoreData

// Create an instance of APCoreDataStack
let coreDataStack = APCoreDataStack()

// Create a managed object context
let managedContext = coreDataStack.managedObjectContext

// Create an entity description for your data model
let entityDescription = NSEntityDescription.entity(forEntityName: "Person", in: managedContext)!

// Create a new managed object
let person = NSManagedObject(entity: entityDescription, insertInto: managedContext)

// Set attribute values
person.setValue("John", forKey: "name")
person.setValue(25, forKey: "age")

// Save changes
try? managedContext.save()

// Fetch existing data
let fetchRequest = NSFetchRequest(entityName: "Person")
let persons = try? managedContext.fetch(fetchRequest)

// Perform operations on fetched data
for person in persons ?? [] {
  let name = person.value(forKey: "name") as? String
  let age = person.value(forKey: "age") as? Int
  print("Name: \(name ?? "Unknown"), Age: \(age ?? 0)")

Advanced Features

APCoreData provides several advanced features that enhance your experience with Core Data.

Batch Updates

APCoreData allows you to perform efficient batch updates on your Core Data entities.

  1. Create an instance of APCoreDataBatch to batch update your entities.
  2. Call the updateEntities(_:withPredicate:) function to perform the batch update.

CloudKit Integration

APCoreData seamlessly integrates with CloudKit to provide synchronization capabilities for your Core Data entities.

  1. Enable CloudKit synchronization in your project settings.
  2. Configure the CloudKit settings for your Core Data entities.
  3. Use the provided functions in APCoreDataCloudKitManager to synchronize your entities with CloudKit.

Frequently Asked Questions

Q: Can I use APCoreData with SwiftUI?
A: Yes, you can use APCoreData with SwiftUI. Simply import the framework and utilize the provided APIs to work with your Core Data entities in a SwiftUI environment.
Q: How can I perform complex queries with APCoreData?
A: APCoreData supports complex queries by utilizing NSPredicates. You can create NSPredicate instances and pass them to fetch requests to filter your results based on various conditions.
Q: Does APCoreData support automatic migration of Core Data models?
A: Yes, APCoreData handles automatic migration of Core Data models. It detects changes in your data model and applies the necessary migrations automatically during app launch.

We hope this documentation provides you with all the necessary information to get started with APCoreData. For detailed information on all available features and APIs, please refer to our official documentation.