tezvyn:

📱Mobile Dev

Mobile app development across platforms

1325 bites

More in Mobile Dev — page 11

iOS & Swift89 sec read

Animate a SwiftUI Shape morphing point count

WHAT IT TESTS: Driving custom interpolation with animatableData. OUTLINE: Expose a continuous sides value as animatableData so SwiftUI interpolates it, then compute the path from that fractional value each frame.

iOS & Swift86 sec read

Build an interruptible custom VC transition

WHAT IT TESTS: The custom transition protocol stack. OUTLINE: A delegate vends an animator (UIViewControllerAnimatedTransitioning) for the visuals and an interactive controller (UIViewControllerInteractiveTransitioning) driven by a pan to scrub progress and…

iOS & Swift84 sec read

Diagnose dropped frames during animation

WHAT IT TESTS: Profiling rendering with Instruments and fixing GPU hot spots. OUTLINE: Use Core Animation and color-debug options to spot off-screen passes, blending, and overdraw; cache, flatten, and set shadowPath.

iOS & Swift81 sec read

Allow simultaneous pan and pinch gestures

WHAT IT TESTS: Simultaneous gesture recognition via the delegate. OUTLINE: Attach pan and pinch recognizers, set yourself as delegate, return true from shouldRecognizeSimultaneouslyWith, apply translation to center and scale to transform.

iOS & Swift89 sec read

Build a custom circular progress bar in UIKit

WHAT IT TESTS: Vector drawing with CAShapeLayer plus strokeEnd animation. OUTLINE: Draw an arc with UIBezierPath, assign it to a CAShapeLayer path, set lineWidth and no fill, animate strokeEnd 0 to 1.

iOS & Swift84 sec read

Difference between frame, bounds, and center

WHAT IT TESTS: Coordinate systems and transform effects. OUTLINE: frame and center are in the superview's space; bounds is the view's own space, usually origin zero. A non-identity transform makes frame undefined to read.

iOS & Swift81 sec read

Add shadow and rounded corners to a UIView

WHAT IT TESTS: CALayer shadow and corner properties plus the masksToBounds conflict. OUTLINE: cornerRadius needs masksToBounds true, but that clips the shadow; set shadowPath to keep both and stay performant.

iOS & Swift78 sec read

Implicit .animation() vs explicit withAnimation

WHAT IT TESTS: How SwiftUI ties animation to state changes. OUTLINE: .animation(value:) animates a view when a tracked value changes; withAnimation wraps the state mutation so all dependent views animate.

iOS & Swift88 sec read

What is an actor and how does it prevent data races

WHAT IT TESTS: Actor isolation as compiler-enforced safety. OUTLINE: Actors serialize access to mutable state, reachable only via await; compiler blocks unsafe access. Token-refresh actor coalesces concurrent refreshes.

iOS & Swift83 sec read

How task cancellation works with async/await

WHAT IT TESTS: Cooperative cancellation in Swift Concurrency. OUTLINE: Cancellation is a flag, not a kill; check Task.isCancelled or call checkCancellation, URLSession throws CancellationError automatically.

iOS & Swift78 sec read

Add a default header to every URLSession request

WHAT IT TESTS: Knowing URLSession is configured, not just used. OUTLINE: Set httpAdditionalHeaders on a URLSessionConfiguration, build the session from it, mention per-request overrides win. RED FLAG: Subclassing URLRequest or mutating every request by hand.

iOS & Swift86 sec read

What is @MainActor and why does it matter?

WHAT IT TESTS: thread safety for UI updates. OUTLINE: @MainActor is a global actor guaranteeing code runs on the main thread; annotate UI-updating types or methods so post-network state changes are main-thread safe.

iOS & Swift2 min read

Run two API calls concurrently with async let

WHAT IT TESTS: structured concurrency for parallel work. OUTLINE: use async let to start two independent fetches that run concurrently, then await both, so total time approaches the slower call rather than the sum.

iOS & Swift2 min read

URLSession data vs download vs upload tasks

WHAT IT TESTS: choosing the right URLSession task. OUTLINE: data tasks buffer responses in memory for small API calls; download tasks stream to a file and support background transfers for large files; upload tasks send bodies from data or files and report…

iOS & Swift83 sec read

Map JSON keys to differently named Codable properties

WHAT IT TESTS: Codable key customization. OUTLINE: declare a nested CodingKeys enum mapping userID to the raw value "user_id", or set the decoder's keyDecodingStrategy to convertFromSnakeCase for blanket conversion.

iOS & Swift78 sec read

Fetch and decode JSON with async/await and URLSession

WHAT IT TESTS: modern networking basics. OUTLINE: call URLSession.shared.data(from:) inside an async throws function, check the HTTPURLResponse status, then JSONDecoder().decode([User].self) and let errors propagate via try.

iOS & Swift2 min read

Design offline-first sync and conflict resolution

WHAT IT TESTS: offline-first sync design. OUTLINE: queue local mutations with timestamps and sync state, push and pull deltas using a change token or updatedAt cursor, and resolve conflicts with a chosen policy like last-write-wins or field-level merge.

iOS & Swift2 min read

Bulk-import large JSON into Core Data efficiently

WHAT IT TESTS: knowing the batch APIs. OUTLINE: use NSBatchInsertRequest to write rows directly to the store, bypassing context object materialization, for huge memory and speed wins; limitation is it skips validation, relationships, and does not notify…

iOS & Swift2 min read

Optimize a slow NSFetchedResultsController screen

WHAT IT TESTS: Core Data fetch tuning. OUTLINE: set fetchBatchSize so rows load in pages, use relationshipKeyPathsForPrefetching to avoid per-row faulting round trips, and add indexes matching sort and predicate to make queries fast.

iOS & Swift87 sec read

Why store auth tokens in Keychain, not UserDefaults?

WHAT IT TESTS: secure credential storage. OUTLINE: UserDefaults is an unencrypted plist readable from backups and on jailbroken devices; use Keychain Services, which stores encrypted items with access control; save with SecItemAdd and read with…