yoklainterview sim

iOS (Swift) Mobile Interview Questions

450 verified iOS (Swift) Mobile interview questions — solve with answers, learn from explanations, test yourself in a real simulation.

Try the real simulation →

Sample questions

Ios Core Data Swiftdata PersistenceDifficulty 1
In Core Data, what is NSManagedObjectContext primarily responsible for?
  • aCompiling the app's data model file into Swift classes.
  • bRendering the app's UI whenever data changes.
  • cEncrypting the SQLite file on disk.
  • dTracking in-memory changes to managed objects and coordinating saves to the persistent store
Explanation:NSManagedObjectContext is the scratchpad that tracks inserted/updated/deleted managed objects and is responsible for saving those changes down to the persistent store coordinator; it does not render UI or handle model compilation.
Ios Core Data Swiftdata PersistenceDifficulty 1
What concurrency type is the default viewContext (NSPersistentContainer.viewContext) configured with?
  • a.privateQueueConcurrencyType.
  • bNo concurrency type — it runs on whichever thread calls it
  • c.mainQueueConcurrencyType
  • d.backgroundQueueConcurrencyType.
Explanation:viewContext is created with .mainQueueConcurrencyType, meaning it is bound to the main thread/queue and is meant to back UI-facing fetches and edits.
Ios Core Data Swiftdata PersistenceDifficulty 2
A developer fetches a large CSV, parses 5,000 rows, and inserts them as managed objects directly on viewContext on the main thread. What is the most likely observable problem?
  • aCore Data silently drops rows past 1,000 to protect memory.
  • bThe insert will fail to compile because viewContext cannot insert objects.
  • cNothing — viewContext is optimized for bulk background work.
  • dThe UI will freeze/stutter
Explanation:viewContext runs on the main queue, so any heavy work performed on it (thousands of inserts plus the eventual save) blocks the main thread and freezes the UI; bulk imports should use a private background context instead.
Ios Core Data Swiftdata PersistenceDifficulty 1
What method creates a new background-queue-bound NSManagedObjectContext that is a child of the persistent container's coordinator?
  • apersistentContainer.newBackgroundContext()
  • bpersistentContainer.viewContext.background()
  • cNSManagedObjectContext.detached().
  • dpersistentContainer.mainContext().
Explanation:newBackgroundContext() returns a private-queue context wired to the same persistent store coordinator, intended for off-main-thread work like imports.
Ios Core Data Swiftdata PersistenceDifficulty 2
let bgContext = container.newBackgroundContext()
let obj = bgContext.object(with: someObjectID)
print(obj.name) // accessed directly from main thread

What is wrong with this code?
  • aThe managed object belongs to a private-queue context
  • bobject(with:) does not exist on NSManagedObjectContext.
  • cNothing is wrong; managed objects are thread-safe by default.
  • dsomeObjectID must be a String, not an NSManagedObjectID.
Explanation:Managed objects are confined to the queue of the context that owns them. Reading obj.name directly from the main thread while bgContext is a private-queue context is a thread-confinement violation; the correct pattern wraps the access in bgContext.perform { ... }.
Ios Core Data Swiftdata PersistenceDifficulty 1
What is NSFetchedResultsController primarily used for?
  • aCompiling the .xcdatamodeld file at build time.
  • bEncrypting fetch requests before they reach SQLite.
  • cMigrating the persistent store schema between versions.
  • dEfficiently driving a table/collection view from Core Data results, tracking inserts/updates/deletes/moves as change notifications
Explanation:NSFetchedResultsController wraps a fetch request and observes context changes, delivering section/row-level insert/delete/update/move notifications so a table or collection view can update incrementally instead of reloading everything.

Test yourself against the 2400-question Mobile bank.

Start interview