Upgrade to Pro — share decks privately, control downloads, hide ads and more …

I Had Three Sources of Truth

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

I Had Three Sources of Truth

You'll see real project code: a Key-Value Store wrapper, a saveRoutes function that writes to SQLite, mirrors to iCloud, updates sync status, and notifies the widget, plus migration logic that uses "max wins" for streaks and totals.

Avatar for Emre Degirmenci

Emre Degirmenci

October 01, 2026

Other Decks in Technology

Transcript

  1. I Had Three Sources of Truth 🚶Walk Mate's data persistence

    journey Emre Degirmenci - @emrdgrmnci - NSSpain XIV
  2. Emre Degirmenci • First time at NSSpain 🇪🇸 • iOS

    Engineer since 2017 • Obsessed with extreme sports 🛹🏂🪁🏄 • Rabbit person 🐰 Emre Degirmenci - @emrdgrmnci - NSSpain XIV LinkedIn
  3. A war story, not a brochure • Real shipping app

    • Real migrations • Real mistakes ME?
  4. What Walk Mate stores now? • Streaks and medals 🥇

    • Total distance 🛣 • Achievements 🎉
  5. What users quietly expect? • Follows me to a new

    phone 📱📲 • Survives reinstall ♻ • Never silently reset my favorites, streak, total walked distance ❌
  6. Four tools, four jobs • UserDefaults ⚙ • NSUbiquitousKeyValueStore 🫙

    • CloudKit / SQLiteData ☁︎ • Game Center 🎮
  7. Era 1: Just UserDefaults 🪨 • Routes and favorites as

    JSON blobs ☁︎ • Zero sync, zero backup 📲
  8. The moment that forced change • New phone 🆕 🤳

    • Restore ♻ • Favorites gone 😱
  9. • Big arrays -> iCloud Drive JSON files • Why?

    The 1 MB KVS limit is real 🔪 • Small scalars -> NSUbiquitousKeyValueStore ☁︎ ☁︎ Era 2: Split iCloud
  10. What hurt in Era 2? • Two copies of the

    same data 🪩 • Which one is newer❓ • Functions named backFilliCloudKVSIfNeeded 🤢 🦨
  11. Era 3: One database 🎉 • SQLiteData rows • WalkMateUserStatsRow,

    Route, Favorite, … ♥ • SyncEngine -> CloudKit private DB ⁉ ☁︎ 🧘
  12. Migration is part of the product • Read KVS 📖

    • Read Drive JSON • Read old UserDefaults • Write SQLite ✏ • Max wins for streaks and totals 🎉
  13. Accidental backup: Game Center • Not designed for storage 🫙

    • Leaderboards and achievements encode totals 💥 • Raise if higher ⬆ Never lower ⬇ ’ • User s progress
  14. So… three sources of truth 1. SQLiteData + CloudKit 2.

    iCloud KVS / Drive mirrors 3. Game Center lower bounds
  15. Five things I d tell my past self 🗣 1.

    Pick storage by size and importance 2. UserDefaults is a settings file ⚙ 3. Every mirror is a future merge bug 🪲 4.Migrations are forever 🔁 ’ 5. Redundancy beats elegance when streaks are on the line
  16. A simple decision map 🧘 ‣ Tiny per-device setting ->

    UserDefaults ‣ Tiny synced scalars -> iCloud KVS ‣ Growing user data -> SQLite / CloudKit ‣ Monotonic public totals -> Game Center (as floor only)
  17. Recap Era 1: one device, then streaks gone Era 2:

    two iCloud tools, then merge pain Era 3: one database, then migration forever
  18. 🇹🇷 Thank you NSSpain! 🇪🇸 Emre Degirmenci - @emrdgrmnci -

    @emredeg.bsky.social - in/aemrdgrmnci - NSSpain XIV