jwonylee iOS Development Notes
website·Indexed 30 days ago
https://jwonylee.github.ioA collection of technical notes and study materials focused on iOS development. Topics include Swift language features (Optionals, Protocols, Hashable), UIKit components (UIViewController, UIStackView, Auto Layout), memory management (ARC, autorelease), concurrency (GCD, DispatchQueue), and data persistence with Core Data and UserDefaults.
What's inside jwonylee iOS Notes
- ReactorKit is a reactive, unidirectional application architecture framework for Swift, combining concepts from Flux and Reactive Programming. It separates the UI layer (View) from the business logic layer (Reactor) to ensure a clean control flow and improve testability.
Overview of UIStackView
UIStackView is a streamlined interface for laying out a collection of views in either a column or a row. It allows developers to create interfaces that respond dynamically to device orientation, screen size, and available space changes. It is similar to Android'sLinearLayout. UIStackView manages the layout of all views contained in itsarrangedSubviewsproperty, ordering them based on the sequence in which they were added.@MainActor class UIStackView: UIViewOverview of the Foundation Framework
The Foundation framework provides a fundamental base layer of functionality used across macOS, iOS, watchOS, and tvOS SDKs. It handles core system tasks including data storage and persistence, text processing, date and time calculations, sorting and filtering, and networking.Principles of Functional Programming
Functional programming relies on two core concepts:
- First-Class Citizens: Functions must be treatable as variables, meaning they can be stored in constants/variables, returned from other functions, and passed as parameters.
- Pure Functions: Functions that exhibit referential transparency, meaning they do not depend on or modify global state and always produce the same output for the same input.
/* This is NOT a pure function because it depends on the global 'rate' variable */ var rate = 1120 func krw(usd: Int) -> Int { return usd * rate }Manage multiplexing and streams in HTTP/2.0
HTTP/2.0 introduces streams to reduce latency and improve efficiency:
- Definition: A stream is an independent, bidirectional sequence of frames exchanged between client and server over a single connection.
- Multiplexing: Multiple streams can be open simultaneously on one TCP connection.
- Identification: Each stream has a unique 31-bit unsigned integer identifier.
- Prioritization: Streams can be assigned priorities.
- Creation: Clients and servers can create streams unilaterally without negotiation, eliminating the need for additional TCP packet exchanges during stream setup.
Understand the fundamentals of iOS Auto Layout
Auto Layout is a system that dynamically calculates the size and position of all views in a view hierarchy based on a set of constraints. Unlike frame-based layouts, which require manual calculation of coordinates, Auto Layout defines relationships between views, allowing the UI to respond dynamically to both external and internal changes.Understand HTTP caching benefits and core concepts
Web caches are HTTP devices that automatically store copies of frequently used documents to provide the following benefits:
- Cost Reduction: Reduces unnecessary data transfer and network costs.
- Latency Reduction: Decreases network bottlenecks and reduces delays caused by physical distance (speed of light).
- Server Load Reduction: Decreases the number of requests hitting the origin server, allowing it to respond faster.
Key Terminology:
- Cache Hit: A request is processed using a copy already present in the cache.
- Cache Miss: No copy is available, and the request is forwarded to the origin server.
- Freshness Check (HTTP Revalidation): The process of verifying with the origin server if a cached copy is still current.
- Revalidation Hit (Slow Hit): When a cache sends a small revalidation request and the server responds with
304 Not Modified, indicating the copy is still valid.
Use SwiftGen for type-safe resource management in iOS
SwiftGen generates Swift code for assets, eliminating the need for string-based lookups and force-unwrapping (UIImage(named: "...")!). It allows for selective building of assets, meaning you can configure which specific asset categories to generate code for. This improves app stability by catching missing resources at compile-time rather than runtime.Understand the role and types of HTTP Proxies
An HTTP proxy acts as an intermediary between a client and a server, organizing the HTTP messages exchanged between them. A proxy server functions as both a web server (to the client) and a web client (to the destination server). While proxies typically connect applications using the same protocol, gateways connect those using different protocols, though the distinction is often blurred in practice.Understand HTTPS and SSL/TLS Fundamentals
HTTPS is a secure version of HTTP that combines the HTTP protocol with a set of symmetric and asymmetric certificate-based encryption techniques. It ensures that all HTTP request and response data is encrypted before being transmitted over the network. The underlying security layers are provided by SSL (Secure Sockets Layer) and its successor, TLS (Transport Layer Security).Identify HTTP clients using headers and network info
Since HTTP is a stateless protocol, servers can use the following methods to identify clients or gather information about them:
- User-Agent Header: Provides the browser name, version, and sometimes the operating system.
- IP Address: The server can identify the IP address of the opposite end of the TCP connection.
- From Header: Historically used to include the user's email address, though rarely used by modern browsers due to spam concerns.
- WWW-Authenticate and Authorization Headers: Used by HTTP's built-in authentication system to transmit usernames for easier login.
Understand HTTP basic request and response flow
HTTP is an application layer protocol where a client sends an HTTP request to a server, and the server returns the requested data as an HTTP response. Every HTTP request message contains exactly one method. The response includes a three-digit status code that informs the client whether the request was successful or if further action is required. The response body can contain arbitrary binary data.