iOS

Core Data

Core Data stack, NSManagedObject, fetch requests, relationships, migrations, performance

22 питань зі співбесід·
Mid-Level
1

What is NSPersistentContainer in Core Data?

Відповідь

NSPersistentContainer encapsulates the entire Core Data stack including NSPersistentStoreCoordinator, NSManagedObjectContext, and NSPersistentStore. It simplifies initialization by automatically managing configurations and reduces boilerplate code compared to old manual approach. Using NSPersistentContainer is the recommended practice since iOS 10 for quick and thread-safe Core Data setup.

2

What is the main role of NSManagedObjectContext?

Відповідь

NSManagedObjectContext acts as an in-memory scratch pad between the application and persistent storage layer. It manages CRUD operations, tracks all changes with undo/redo, and coordinates saves to persistent store. A context is bound to a specific queue and must never be shared between threads. Use perform() for any thread-safe interaction.

3

What is an NSManagedObject?

Відповідь

NSManagedObject is the base class for all persistent objects in Core Data. It represents a unique instance of an entity defined in the data model with a unique objectID. NSManagedObject automatically manages properties via KVC, bidirectional relationships, and object state (inserted, updated, deleted) within the context. Subclassing NSManagedObject allows adding business logic.

4

How to initialize an NSFetchRequest to retrieve entities?

5

Which object is responsible for communication with the storage layer?

+19 питань зі співбесід

Опануй iOS для наступної співбесіди

Отримай доступ до всіх питань, flashcards, технічних тестів, вправ code review та симуляторів співбесід.

Почни безкоштовно