tezvyn:

📱Mobile Dev

Mobile app development across platforms

1323 bites

More in Mobile Dev — page 51

iOS & Swift2 min read

Xcode Project: Your App's Blueprint and Toolbox

An Xcode project is a self-contained kit for your app, holding all files, assets, and build instructions. It's the central repository for source code, build settings, and dependencies. The footgun: moving files in Finder without telling Xcode breaks builds.

iOS & Swift2 min read

Opaque Types: Hide Implementation, Not Capabilities

Opaque types (`some Protocol`) hide a function's concrete return type, exposing only its protocol conformance. This lets you change the implementation later (e.g., from `ReverseCollection`) without breaking client code that just needs `some Collection`.

Key-Path Expressions: Type-Safe Pointers to Properties
iOS & Swift2 min read

Key-Path Expressions: Type-Safe Pointers to Properties

A key path is a type-safe "pointer" to a property, like `\User.name`. It lets you pass around a reference to a property itself, not just its value, making it ideal for generic sorting or SwiftUI data binding. The footgun is forgetting they are strictly typed.

iOS & Swift2 min read

Associated Types: Making Protocols Generic

Associated types make protocols generic. Think of them as a "fill-in-the-blank" type name. A protocol like `Sequence` has an `Element` type, which a conforming `Array<String>` fills in as `String`.

iOS & Swift2 min read

Copy-on-Write (CoW) in Swift

Copy-on-write lets Swift's Array, Dictionary, Set, and String share one underlying buffer across copies until one is mutated, giving full value-type semantics with the performance of sharing, deferring the actual copy until it is truly needed.

iOS & Swift2 min read

Retain Cycles and Capture Lists in Swift

A retain cycle is a memory leak where two objects hold strong references to each other, preventing deallocation. This often happens in closures that capture `self`, like network callbacks.

iOS & Swift2 min read

Protocol Extensions: Default Behavior for Free

Protocol extensions give conforming types default functionality "for free," like a standard toolkit with every blueprint. Use them to add common behavior to your protocols or even extend system types.

The Result Type: Modeling Success and Failure
iOS & Swift2 min read

The Result Type: Modeling Success and Failure

The Result type is a sealed box for an operation's outcome: it holds either a success value or a failure error. It's used in asynchronous code like network requests to create clean, explicit completion handlers. The footgun is forgetting to handle both cases.

iOS & Swift2 min read

Value vs. Reference Semantics in Swift

Value types are like emailing a document copy; changes don't affect the original. Reference types are like a shared Google Doc link; everyone edits the same instance. In Swift, `structs` are copies, while `classes` are shared references.

iOS & Swift2 min read

async/await: Write Concurrent Code That Reads Synchronously

async/await lets you write asynchronous code that reads like a synchronous story, eliminating callback hell. It's ideal for network requests or file I/O. The footgun is thinking `await` blocks a thread; it only suspends the current task.

iOS & Swift2 min read

Automatic Reference Counting (ARC): Swift's Memory Manager

ARC is Swift's automatic memory manager for classes. It's like a landlord tracking tenants: when the last reference to an object is gone, its memory is freed. It's used everywhere in Swift, but the footgun is creating strong reference cycles.

iOS & Swift2 min read

Protocols: Swift's Blueprint for Behavior

Protocols are Swift's blueprints for behavior, enabling composition over inheritance. They're used to decouple dependencies and define shared functionality like `Codable`. The footgun is mistaking `any Protocol` for `some Protocol`, inviting performance costs.

iOS & Swift2 min read

Swift Error Handling: Throwing, Catching, and Propagating

Swift error handling uses a dedicated channel for failures. Functions declare they can fail with `throws`, you handle them with `do-catch`, or transform them into optionals with `try?`. The footgun is overusing `try!`, which crashes your app on failure.

iOS & Swift2 min read

Swift Structs vs. Classes: Value vs. Reference Types

In Swift, a struct is a copied value (like a new document), while a class is a shared reference (like a link to one document). Use structs for simple data like coordinates; use classes for shared state like a user session.

iOS & Swift2 min read

Swift Optionals: Handling Nothing Safely

An Optional is like a box that might contain a value or might be empty (`nil`). You must safely unwrap it before using the value, preventing crashes. It's used for properties that might not exist yet or for function returns that can fail.

iOS & Swift2 min read

Swift Control Flow: Directing Your Code's Path

Control flow statements are the traffic signals of your code. They use keywords like `if`, `for`, and `switch` to make decisions and repeat actions, rather than just running top-to-bottom. This is how you show a list of items or check if a user is logged.

iOS & Swift2 min read

Variables and Constants in Swift

Swift has two ways to store a value: var declares a variable you can reassign later, and let declares a constant whose value is set once and can never change, and Swift's convention is to default to let unless you have a specific reason to need var.

Flutter & Dart2 min read

Performance Profiling in Tests

Performance profiling in tests means capturing frame build and raster times during a scripted, automated run instead of eyeballing smoothness, so jank regressions get caught in CI before they ever reach a real device.

Flutter & Dart2 min read

Flutter Nested Navigation: Routers Within Routers

Nested Navigation is like having a mini-app with its own back button inside a single screen. It's used for UIs like a BottomNavigationBar where each tab needs its own navigation history. The footgun is calling the wrong Navigator's context.

Flutter & Dart2 min read

Flutter's `compute`: Offload Heavy Work from the UI Thread

Flutter's `compute` function runs heavy calculations in the background to prevent your app's UI from freezing. Use it for tasks like parsing large JSON or complex math. The footgun: on the web, it runs on the same event loop, not in a true parallel thread.