iOS

Core Data

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

22 pertanyaan wawancaraยท
Mid-Level
1

What is NSPersistentContainer in Core Data?

Jawaban

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?

Jawaban

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?

Jawaban

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 pertanyaan wawancara

Kuasai iOS untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis