Swift (iOS/macOS) and Databases: A Practical Guide
300 pages
English
PDF
4.5

Swift (iOS/macOS) and Databases: A Practical Guide

Swift (iOS/macOS) and Databases: A Practical Guide

Author:

Year:

Summary:

The book "Swift (iOS/macOS) and Databases: A Practical Guide" is a comprehensive resource for developers looking to master working with databases in the Apple ecosystem. It covers all key data storage technologies used in applications for iOS, macOS, watchOS, and tvOS, and offers ready-made solutions for everyday tasks.



Who is this book for?

  • Beginning iOS/macOS developers who want to understand how to properly store data in an application.
  • Experienced programmers wishing to deepen their knowledge of Core Data, Realm, and SQLite, as well as master modern approaches (SwiftData, CloudKit).
  • Students and instructors of mobile development courses.
  • Anyone transitioning from other languages (Python, Java) to Swift and wanting to quickly get up to speed with local and remote databases.


What will you learn from the book?

  • Core Data Basics: data model, NSManagedObject, contexts, queries (NSFetchRequest), migrations, and performance.
  • Alternatives to Core Data: Realm (object-oriented database), SQLite via FMDB/GRDB, Firebase Firestore for real-time.
  • Modern SwiftData: Apple's new framework for iOS 17+ and macOS 14+: @Model, @Query, SwiftUI integration.
  • Cloud Synchronization: CloudKit, iCloud, working with remote data, offline mode.
  • Architecture and Patterns: Repository, Unit of Work, MVVM + Core Data, database testing.
  • Optimization: indexes, prefetching, batch updates, working with large data, memory management.


Structure and Practical Value

The book is built on the principle of "from simple to complex." Each chapter contains:

  • A theoretical introduction explaining concepts.
  • Step-by-step code examples in Swift (Xcode 15+, Swift 5.9+).
  • Ready-made snippets for use in real projects.
  • Tips for avoiding common mistakes (memory leaks, race conditions, UI blocking).
  • Exercises to reinforce the material.


At the end of the book, you will find an application — a task manager using SwiftData and CloudKit — that combines all the technologies studied.



Why should you read this book?

  • Relevance: all examples correspond to the latest versions of Swift and Apple frameworks.
  • Practice: over 50 ready-made projects and code snippets.
  • Versatility: suitable for both iOS and macOS (including Catalyst).
  • Clear language: complex topics are explained accessibly, with metaphors and visualizations.


This book will become your reliable companion when creating applications with local and remote data storage. Whether you are building a simple to-do application or a complex corporate system, you will find all the necessary tools and best practices here.

Recommendations