Collection

UIKit sample architecture

Source-backed, high-level architecture notes for Apple sample-code pages grouped in the UIKit folder.

  • Catalog module label: UIKit
  • Coverage: 48 / 48 sample pages documented
  • Source policy: archive hashes and extracted-tree references are verified locally before analysis

Samples

Sample Platforms High-level architecture Documented patterns
Add Home Screen quick actions iOS, iPadOS, Mac Catalyst SceneDelegate is the quick-action coordinator; it translates scene callbacks into navigation over a small shared contact store. Scene lifecycle adapter, Shared in-memory store, Value model, Framework delegate
Adding context menus in your app iOS, iPadOS, Mac Catalyst A storyboard-driven example matrix shares base list controllers and protocol-extension action factories; each concrete screen owns one UIKit integration variant. Protocol extension, Example matrix, Template superclass, Framework delegate, Diffable data source
Adding hardware keyboard support to your app iOS, iPadOS, Mac Catalyst A scene-owned split controller composes file-list and canvas responders; AppDelegate publishes global commands whose selectors travel down UIKit’s responder chain. Responder chain command routing, Capability protocol, Split-view composition, Weak delegate, Diffable data source
Adding menus and shortcuts to the menu bar and user interface iOS, iPadOS, Mac Catalyst AppDelegate owns main-menu construction/validation; split-view controllers own item state and responder actions; Catalyst toolbar behavior is isolated in an extension. Menu builder, Responder chain, Weak delegate, Platform adapter extension, Observer
Adjusting your layout with keyboard layout guide iOS, iPadOS, Mac Catalyst One programmatic view controller creates the hierarchy and registers edge-conditioned constraints with UIKeyboardLayoutGuide. Adaptive constraint set, View factory helper, View-controller composition
Adopting drag and drop in a custom view iOS, iPadOS, Mac Catalyst One view controller owns the image UI; separate extensions adapt it to drag-source and drop-destination delegate protocols. Framework delegate, Extension-based decomposition, Transfer object, Local fast path
Adopting drag and drop in a table view iOS, iPadOS, Mac Catalyst TableViewController owns one mutable Model; feature extensions divide standard table data, drag production, and drop consumption. MVC, Framework delegate, Encapsulated mutable model, Extension-based decomposition, Transfer object
Adopting hover support for Apple Pencil iOS, iPadOS, Mac Catalyst A storyboard-hosted HoverDrawView owns gesture, path, preview, and rendering state; its view controller is only a host. Custom view state owner, Gesture recognizer adapter, Two-phase rendering, Lifecycle-managed resources
Adopting iOS Dark Mode iOS, iPadOS, Mac Catalyst A storyboard catalog pairs Before1... and After2... controllers; each screen is an independent migration example rather than a shared feature pipeline. Before-after example matrix, Trait-context capture, Main-thread handoff, Scoped appearance override
Adopting menus and UIActions in your user interface iOS, iPadOS, Mac Catalyst A root custom menu control navigates to independent programmatic demo controllers; each screen owns one menu API variation. Action-as-value, Example catalog, Custom control, Deferred provider, Lifecycle timer
Asynchronously loading images into table and collection views iOS, iPadOS, Mac Catalyst Table and collection controllers share a process-wide ImageCache; Item identities anchor diffable snapshots, while a custom URL protocol simulates cancellable latency. Shared cache, Request coalescing, Diffable identity, Async main-thread handoff, Protocol test double
Building a document browser app for custom file formats iOS, iPadOS, Mac Catalyst A document-browser root opens Document values into a compound editor; Quick Look preview/thumbnail targets reuse the same document and particle renderer. Document model, Compound view controller, Shared renderer, Framework delegate, Extension target adapter
Building an app with a document browser iOS, iPadOS, Mac Catalyst A browser scene routes incoming file intents to a browser/controller boundary; a UIDocument subclass owns file state, and an editor controller owns visible editing. Document model, Scene intent routing, Weak delegate, Observer-backed state, Document browser transition
Building and improving your app with Mac Catalyst iOS, iPadOS, Mac Catalyst A three-column split-view coordinator owns browser state; protocol-composed values are type-erased for heterogeneous UI; scene delegates adapt state and Mac-only chrome. Split-view coordinator, Protocol composition, Type erasure, Observable selection model, Scene state restoration, Platform adapter
Building high-performance lists and collection views iOS, iPadOS, Mac Catalyst The scene injects model/asset stores into a grid controller; the controller coordinates diffable UI and request lifetimes; AssetStore owns a multi-tier image pipeline. Dependency injection, Diffable data source, Prefetch and cancellation, Multi-tier cache, Shared publisher, Protocol-backed store
Changing the appearance of selected and highlighted cells iOS, iPadOS, Mac Catalyst A storyboard connects a collection view to one controller acting as data source/delegate; a custom cell owns reusable visual-state presentation. Framework-managed visual state, Delegate callbacks, Reusable cell encapsulation
Creating self-sizing table view cells iOS, iPadOS, Mac Catalyst A view controller retains an extracted data source; the data source registers/configures cells; each cell owns a complete intrinsic-content constraint chain. Extracted data source, Intrinsic-content sizing, Dynamic Type, Factory method, Constraint-driven layout
Customizing an image picker controller iOS, iPadOS, Mac Catalyst One feature controller owns the picker, overlay controls, capture timer, and captured-image session; UIKit and AVFoundation provide delegate and authorization boundaries. Framework controller customization, Delegate callback, Overlay view, Timer-driven commands, Permission gate
Customizing and resizing sheets in UIKit iOS, iPadOS, Mac Catalyst The postcard controller creates and configures presented controllers; a settings sheet edits one shared presentation-settings object and reapplies it to its own adaptive sheet. Presentation coordinator, Shared settings object, Custom detent strategy, Live sheet mutation, Framework delegates
Customizing collection view layouts iOS, iPadOS, Mac Catalyst A friends list and photo feed share model/cell conventions but plug different UICollectionViewLayout strategies into separate collection controllers. Layout strategy, Template method, Attribute cache, Batch-update command model, Reuse identity guard, MVC
Customizing your app’s navigation bar iOS, iPadOS, Mac Catalyst, macOS, tvOS, visionOS, watchOS A table-driven catalog routes to small example controllers; each example owns only its UINavigationItem/toolbar configuration, while the navigation controller owns stack/chrome lifetime. Example-per-controller catalog, Navigation-stack coordination, Framework-owned configuration, Extracted data source, Target-action
Data delivery with drag and drop iOS, iPadOS, Mac Catalyst The domain object implements item-provider read/write protocols; a table controller adapts drag/drop sessions to one data-source owner and commits asynchronous external loads into the table. Transferable model, Multiple representations, Drag/drop adapter, Async placeholder commit, Local fast path, Extracted data source
Detecting changes in the preferences window iOS, iPadOS, Mac Catalyst Settings.bundle declares preferences; the app delegate recursively registers defaults; the main controller maps a persisted integer to UI color and retains one reactive subscription. Declarative settings schema, Default registration, Reactive binding, Enum mapping, UserDefaults facade
Disabling the pull-down gesture for a sheet iOS, iPadOS, Mac Catalyst The root owns committed text; the edit controller owns a transactional copy and derived dirty state; two delegate seams coordinate commit/cancel and adaptive-presentation attempts. Edit transaction, Derived dirty state, Weak delegate, Adaptive-presentation guard, Confirmation flow
Display text with a custom layout iOS, iPadOS, Mac Catalyst One app-owned NSTextStorage feeds feature-specific TextKit stacks owned by three view-controller subclasses. Shared TextKit model, Strategy by subclass, Delegate extension, Observation token ownership
Displaying searchable content by using a search controller iOS, iPadOS, Mac Catalyst MainTableViewController coordinates the source catalog, search controller, results controller, navigation, and restoration state. Search coordinator, Filtered projection, Delegate adapters, State restoration
Enhancing your iPad app with pointer interactions iOS, iPadOS, Mac Catalyst ViewController coordinates tools, while QuiltView owns stitch state, persistence, drawing, taps, and its editor pointer interaction. Custom view state owner, Weak delegate, Pointer style strategies, Composite view
Enriching your text in text views iOS, iPadOS, Mac Catalyst, macOS, visionOS SwiftUI owns navigation; thin representables construct platform views, and each platform container owns one independent TextKit demonstration. SwiftUI adapter layer, Platform abstraction, Feature-slice views, TextKit delegate filtering
Illustrating the force, altitude, and azimuth properties of touch input iOS, iPadOS, Mac Catalyst The controller receives UIKit touch callbacks; CanvasView converts each touch stream into Line models and renders them, while ReticleView presents current diagnostics. Input pipeline, Touch-to-model identity map, Two-tier rendering, Protocol extension formatting
Implementing modern collection views iOS, iPadOS, Mac Catalyst, macOS This is a suite of independent demonstrations: each screen/window controller owns its layout, data source, identifiers, and snapshots; selected helpers model dynamic data. Feature-catalog architecture, Controller-owned diffable state, Snapshot projection, Configuration protocol
Implementing Peek and Pop iOS, iPadOS, Mac Catalyst A base table controller owns catalog behavior; two subclasses isolate storyboard-versus-code preview setup, and an injected detail controller mutates the selected model. Template Method base controller, Preview-commit flow, Injected shared model, Notification observation
Integrating pointer interactions into your iPad app iOS, iPadOS, Mac Catalyst One screen controller coordinates interactions; custom views own geometry/state, while capability extensions separate pointer, button-provider, and context-menu callbacks. Controller as interaction adapter, Shape strategy hierarchy, Capability extensions, Custom control encapsulation
Leveraging touch input for drawing apps iOS, iPadOS, Mac Catalyst CanvasMainViewController composes recognizers, model, renderer, scroll container, and tools; custom recognizers create Stroke data consumed by StrokeCGView. Custom gesture adapter, Stroke model pipeline, Sequence iterator, Incremental renderer
Navigating an app’s user interface using a keyboard iOS, iPadOS, Mac Catalyst A split-view coordinator hosts a protocol-driven menu; each sample type describes and constructs an independent feature controller using shared layout/data helpers. Protocol-driven feature catalog, Split-view coordinator, Responder chain command, Generic view composition
Prefetching collection view data iOS, iPadOS, Mac Catalyst One CustomDataSource is both the collection view data source and prefetch data source; it delegates asynchronous, cached, identifier-based work to AsyncFetcher. Prefetch adapter, Request coalescing, Cache-aside fetch, Reuse identity guard, Cancellable operation
Restoring your app’s state iOS, iPadOS, Mac Catalyst A singleton data-model manager owns durable JSON state; main and image scene delegates reconstruct scene-specific UI from lightweight NSUserActivity mementos. Activity memento, Scene router, Shared data model, Stable identity, Legacy restoration bridge
Selecting multiple items with a two-finger pan gesture iOS, iPadOS, Mac Catalyst Two sibling controllers own small demo models and adapt UIKit’s table and collection multiple-selection callbacks into editing state. Parallel view-controller implementations, Framework callback boundary, Controller-owned models
Showing help tags for views and controls using tooltip interactions iOS, iPadOS, Mac Catalyst ViewController composes tooltip-enabled views; UIToolTipInteraction delegates either remain on the controller or move into custom view subclasses that calculate their own configuration. Interaction-object composition, Delegate-configured behavior, Self-contained custom views
Supporting desktop-class features in your iPad app iOS, iPadOS, Mac Catalyst DocumentBrowserViewController opens a MarkdownDocument and presents a SplitViewController, which owns editor and outline children; local delegates synchronize parsed outline state and document edits. Document-controller composition, Local delegate coordination, Background parse and preview pipeline
Supporting gesture interaction in your apps iOS, iPadOS, Mac Catalyst ViewController coordinates pan, pinch, rotation, and a custom ResetGestureRecognizer; the custom recognizer owns touch history and publishes state transitions back through UIKit target-action. Gesture recognizer state machine, Target-action coordination, Framework delegate policy
Supporting HDR images in your app iOS, iPadOS, Mac Catalyst, macOS MainView owns navigation and import/export state, creates an actor-isolated EditedAsset, and delegates Core Image rendering to Renderer; RenderView adapts the resulting pixel buffer to UIKit or AppKit. Observable editing model, Renderer service, Platform view adapter
Supporting multiple windows on iPad iOS, iPadOS, Mac Catalyst AppDelegate selects a scene configuration from an activity type, GalleryViewController requests an inspector for a selected Photo, and InspectorSceneDelegate reuses a matching session or creates and restores one. Activity-routed scenes, Session reuse before creation, Restorable activity payload
Synchronizing documents in the iCloud environment iOS, iPadOS, Mac Catalyst MetadataProvider owns NSMetadataQuery and publishes typed change notifications to MainViewController; selecting an item creates a Document for DetailViewController, where package state, peer changes, and conflicts remain behind the UIDocument boundary. Metadata query publisher, Document boundary, Coordinated file access
UIKit Catalog: Creating and customizing views and controls iOS, iPadOS, Mac Catalyst OutlineViewController turns an OutlineItem hierarchy into a diffable sidebar and routes leaf storyboard names to feature controllers; most feature tables inherit BaseTableViewController and describe control setup with CaseElement closures. Data-driven feature router, Template base controller, Typed configuration closure
Updating collection views using diffable data sources iOS, iPadOS, Mac Catalyst RecipeSplitViewController owns selected collection/recipe state and coordinates sidebar, list, and detail columns; DataStore owns recipe mutations, while sidebar and list controllers render independent diffable snapshots keyed by stable values and Recipe.ID. Split-view state coordinator, Identifier-based snapshots, Notification-driven store updates
Using suggested searches with a search controller iOS, iPadOS, Mac Catalyst MainTableViewController owns the product list, UISearchController, and results controller; ResultsTableController switches between suggestions and filtered products, then reports selections through the local weak SuggestedSearch delegate. Controller-owned search adapter, Weak local delegate, Token-aware filtering
Using SwiftUI with UIKit iOS, iPadOS, Mac Catalyst MainMenuViewController routes to three independent examples: child UIHostingController containment, cell-level UIHostingConfiguration, and a diffable UIKit list whose private observable models bind into editable SwiftUI cell content. Framework adapter bridges, Example factory router, Observable model data flow
Using TextKit 2 to interact with text iOS, iPadOS, Mac Catalyst, macOS Each platform controller constructs NSTextContentStorage, NSTextLayoutManager, and NSTextContainer; its custom TextDocumentView becomes the layout/viewport delegate, maps fragments to layers, and substitutes shared BubbleLayoutFragment instances for comment paragraphs. Explicit TextKit object graph, Viewport rendering adapter, Layout fragment specialization, Parallel platform shells

Cross-sample signals

Recurring documented patterns

Pattern label Sample documents
Framework delegate 5
Weak delegate 5
Diffable data source 3
Extracted data source 3
Extension-based decomposition 2
Transfer object 2
Local fast path 2
MVC 2
Custom view state owner 2
Request coalescing 2
Document model 2
Split-view coordinator 2
Reuse identity guard 2

Type-role naming evidence

Counts below are declaration-name suffixes, not inferred patterns.

Role suffix Distinct declarations across samples
Controller 206
Delegate 93
View 73
Model 10
Provider 9
Store 8
Document 6
DataSource 5
Manager 3
Renderer 2
App 2
Transformer 1
Operation 1
Component 1

Swift access-control evidence

These are declaration occurrences in scanned Swift source, including implicit internal declarations.

Access level Occurrences
implicit internal 7839
private 751
fileprivate 61
public 29
private(set) 9

References

Generated from the verified local catalog and completed Markdown documents.