swift

Local notifications scheduling

Local notifications alert users without server infrastructure. I use UNUserNotificationCenter to schedule notifications at specific times or locations. Creating a notification requires UNMutableNotificationContent with title, body, and sound, plus a t

Push notifications with UserNotifications framework

Push notifications re-engage users with timely content. I use the UserNotifications framework to request authorization and handle notification delivery. The app must register for remote notifications and send the device token to the backend. When noti

MVVM architecture pattern for iOS

MVVM (Model-View-ViewModel) separates concerns cleanly in iOS apps. Models hold data, Views display UI, and ViewModels mediate between them with business logic and state. Views bind to ViewModel properties using Combine or SwiftUI's property wrappers.

Keychain wrapper for secure credential storage

The Keychain securely stores sensitive data like passwords and tokens, encrypting them at the OS level. Direct Keychain APIs are verbose, so I create a wrapper class that simplifies common operations. The wrapper uses Security framework's SecItemAdd,

SwiftUI PreferenceKey for child-to-parent communication

PreferenceKey enables child views to pass data up to ancestors, complementing the typical parent-to-child flow. I define a custom preference key by conforming to PreferenceKey protocol with a defaultValue and reduce method that combines multiple value

Core Data for local persistence

Core Data is Apple's object graph and persistence framework, essential for complex data models and offline support. I define entities and relationships in the .xcdatamodeld file, then generate NSManagedObject subclasses. The NSPersistentContainer enca

Combine framework for reactive programming

Combine provides a declarative Swift API for processing values over time, perfect for handling async events like network requests, user input, and timers. Publishers emit sequences of values, and subscribers receive them. Operators transform, filter,

UserDefaults and app preferences

UserDefaults provides simple key-value storage for app preferences and settings. It persists basic types like strings, numbers, bools, dates, and data automatically. I use UserDefaults for user preferences, app state, and feature flags—never for sensi

JSON encoding and decoding with Codable

Codable protocol combines Encodable and Decodable for seamless JSON conversion. Swift structs and classes conforming to Codable automatically synthesize encoding/decoding logic when all properties are Codable. JSONEncoder converts Swift types to JSON

Coordinator pattern for navigation flow

The Coordinator pattern separates navigation logic from view controllers, promoting reusability and testability. Coordinators own navigation controllers and decide which screens to show based on user actions. Each flow (onboarding, main, settings) has

SwiftUI List with pull-to-refresh and infinite scroll

Lists are fundamental to iOS apps, displaying scrollable collections efficiently. SwiftUI's List or ScrollView with LazyVStack renders items on-demand. I add pull-to-refresh with the .refreshable modifier, calling async refresh logic. For infinite scr

Unit testing with XCTest and mocks

Unit tests verify code behavior in isolation using XCTest framework. I create test classes inheriting from XCTestCase with test prefixed methods. Each test has arrange-act-assert structure: set up dependencies, execute code, verify results with XCTAss