Sample CodemacOSReviewed 2026-07-21View on Apple Developer

Integrating accessibility into your app

At a glance

Item Summary
Purpose Make your app more accessible to users with disabilities by adding accessibility features.
App architecture A C/Objective-C header, Metal, Objective-C, Swift sample with the source-visible chain AppDelegateButtonBaseViewControllerCocoa / simd APIs.
Main patterns View-controller organization, Protocol-oriented abstraction, Delegate or data-source callbacks
Project style 71 scanned source file(s) across C/Objective-C header, Metal, Objective-C, Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: DispatchQueue.main.asyncAfter, RunLoop; none alone proves a background thread.
State/event model No structured observation or publisher-scheduling marker indexed.
Key frameworks/packages Cocoa, Foundation, simd, CoreText, MediaLibrary; these are source dependencies, not architecture labels.

Project structure

Source bundle/
└── AccessibilityUIExamples/
    ├── Application/
    │   ├── AppDelegate.swift
    │   └── MainViewController.swift
    ├── LayoutArea/
    │   └── CustomLayoutAreaView.swift
    ├── RadioButtons/
    │   └── CustomRadioButtonsView.swift
    ├── Stepper/
    │   └── CustomStepperView.swift
    ├── Switches/
    │   └── TwoPositionSwitchView.swift
    ├── Checkbox/
    │   ├── CustomCheckBoxView.m
    │   └── CustomCheckBoxView.swift
    ├── CustomRotors/
    │   ├── ElementView/
    │   │   └── CustomRotorsContainerView.swift
    │   └── TextView/
    │       └── CustomRotorsTextView.swift
    ├── Images/
    │   └── ImageViewLayerView.swift
    └── Outline/
        └── CustomOutlineView.m

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: C/Objective-C header, Metal, Objective-C, Swift.
  • The verified tree contains 29 project/configuration file(s) and 85 source declaration(s).

Overall architecture

Reference code

AccessibilityUIExamples/Application/AppDelegate.swift:10 — architecture anchor

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into Accessibility.

Ownership and state

Ownership evidence

AccessibilityUIExamples/LayoutArea/CustomLayoutAreaView.swift:23 — stored dependency or nearest verified ownership anchor

    struct LayoutInfo {
        static let LayoutItemHandleSize = CGFloat(8.0)
        static let LayoutItemMinSize = CGFloat(LayoutItemHandleSize * 3.0)
        static let LayoutItemMoveDelta = CGFloat(10.0)
        static let LayoutItemSize = CGFloat(50.0)
    }
Owner Object or state Relationship Mutation authority
LayoutInfo CGFloat (LayoutItemHandleSize) owns value state Initialized by the owner; the binding is immutable
LayoutInfo CGFloat (LayoutItemMinSize) owns value state Initialized by the owner; the binding is immutable
LayoutInfo CGFloat (LayoutItemMoveDelta) owns value state Initialized by the owner; the binding is immutable
LayoutInfo CGFloat (LayoutItemSize) owns value state Initialized by the owner; the binding is immutable

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Concurrency, scheduling, and thread safety

Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.

Concern Source mechanism Verified placement or handoff Evidence
Queue scheduling DispatchQueue.main.asyncAfter The source addresses the main dispatch queue. AccessibilityUIExamples/Buttons/CustomButtonView.swift:77
Run-loop scheduling RunLoop The source refers to a run loop; the owning thread requires surrounding evidence. AccessibilityUIExamples/LayoutArea/CustomLayoutAreaView.swift:233

@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.

Reference code

AccessibilityUIExamples/Buttons/CustomButtonView.swift:77 — representative execution boundary

        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delay, execute: {
            onCompletion()
        })

State propagation, frameworks, and dependencies

Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.

Category Mechanism or module Verified role Evidence
Source import Cocoa The cited file imports this module; runtime use and architectural role are not inferred. AccessibilityUIExamples/Application/AppDelegate.swift:8
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. AccessibilityUIExamples/Application/Example.swift:8
Source import simd The cited file imports this module; runtime use and architectural role are not inferred. AccessibilityUIExamples/Stepper/ShaderTypes.h:11
Source import CoreText The cited file imports this module; runtime use and architectural role are not inferred. AccessibilityUIExamples/Text/CoreTextColumnView.swift:10
Source import MediaLibrary The cited file imports this module; runtime use and architectural role are not inferred. AccessibilityUIExamples/Application/DetailViewController.swift:9
Source import metal_stdlib The cited file imports this module; runtime use and architectural role are not inferred. AccessibilityUIExamples/Stepper/Shaders.metal:8

receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.

Class and protocol design

AccessibilityUIExamples/Application/MainViewController.swift:264 — representative type boundary

protocol MainViewControllerDelegate: AnyObject {
    func didChangeExampleSelection(mainViewController: MainViewController, selection: Example?)
}
Type Responsibility Depends on or conforms to
AppDelegate Receives callback-driven events NSObject, NSApplicationDelegate
MainViewControllerDelegate Defines a capability or collaboration contract AnyObject
CustomRotorsElementViewDelegate Defines a capability or collaboration contract AnyObject
CustomRotorsTextViewDelegate Defines a capability or collaboration contract AnyObject
SharedFocusSearchFieldDelegate Defines a capability or collaboration contract AnyObject
CustomLayoutAreaView User-interface presentation and input forwarding NSView, NSAccessibilityLayoutArea
CustomRadioButtonsView User-interface presentation and input forwarding NSView, NSAccessibilityGroup
CustomStepperView User-interface presentation and input forwarding MTKView, NSAccessibilityStepper
TwoPositionSwitchView User-interface presentation and input forwarding NSSlider
MainViewController View lifecycle, callbacks, and feature coordination NSViewController, NSTableViewDelegate, NSTableViewDataSource

The source explicitly defines local protocol relationships: SplitViewControllerMainViewControllerDelegate, CustomSearchFieldViewControllerSharedFocusSearchFieldDelegate.

Access control

Symbol Access Verified effect Likely rationale
numberOfRows (AccessibilityUIExamples/Application/MainViewController.swift:62) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
tableView (AccessibilityUIExamples/Application/MainViewController.swift:66) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
tableView (AccessibilityUIExamples/Application/MainViewController.swift:77) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
addButtonTests (AccessibilityUIExamples/Application/MainViewController.swift:98) fileprivate Use is restricted to this source file. Inference: share with same-file helpers or extensions without exposing the symbol module-wide.

Reference code

AccessibilityUIExamples/Application/MainViewController.swift:62 — representative boundary

    public func numberOfRows(in tableView: NSTableView) -> Int {
        return (examplesArrayController.arrangedObjects as AnyObject).count
    }

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
View lifecycle, callbacks, and feature coordination ButtonBaseViewController, ButtonSubclassViewController, ButtonViewController, ButtonViewSubclassViewController The source’s Controller suffix makes this role explicit.
Receives callback-driven events AppDelegate, CustomRotorsElementViewDelegate, CustomRotorsTextViewDelegate, MainViewControllerDelegate The source’s Delegate suffix makes this role explicit.
User-interface presentation and input forwarding CoreTextColumnView, CoreTextView, CustomButtonView, CustomCheckBoxView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
View-controller organization AccessibilityUIExamples/Buttons/ButtonBaseViewController.swift:10 A controller is the verified coordination boundary; this is MVC-style only where a separate model is present.
Protocol-oriented abstraction AccessibilityUIExamples/Application/SplitViewController.swift:10 A local protocol and concrete conformance create an explicit capability boundary.
Delegate or data-source callbacks AccessibilityUIExamples/Application/AppDelegate.swift:11 Callback protocols invert event delivery back into the sample’s owner.

Naming conventions

  • Types: Controller: ButtonBaseViewController, ButtonSubclassViewController, ButtonViewController, ButtonViewSubclassViewController, ButtonWithImageViewController; Delegate: AppDelegate, CustomRotorsElementViewDelegate, CustomRotorsTextViewDelegate, MainViewControllerDelegate, SharedFocusSearchFieldDelegate; View: CoreTextColumnView, CoreTextView, CustomButtonView, CustomCheckBoxView, CustomLayoutAreaView.
  • Protocols: MainViewControllerDelegate, CustomRotorsElementViewDelegate, CustomRotorsTextViewDelegate, SharedFocusSearchFieldDelegate.
  • Methods: commonInit, layoutItemsInZOrder, bringItemToTop, handleArrowKeys, keyDown, hitTestForLayoutItemAtPoint, hitTestForHandleAtPoint, mouseDown.
  • Files: AccessibilityUIExamples/Application/AppDelegate.swift, AccessibilityUIExamples/LayoutArea/CustomLayoutAreaView.swift, AccessibilityUIExamples/RadioButtons/CustomRadioButtonsView.swift, AccessibilityUIExamples/Stepper/CustomStepperView.swift, AccessibilityUIExamples/Switches/TwoPositionSwitchView.swift, AccessibilityUIExamples/Application/MainViewController.swift.

Architecture takeaways

  • AppDelegate is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches Cocoa, simd, CoreText, MediaLibrary through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • Local protocol relationships provide an explicit substitution boundary.

Source map

Source file Relevant symbols
AccessibilityUIExamples/Application/AppDelegate.swift Cited implementation, Cocoa, AppDelegate
AccessibilityUIExamples/LayoutArea/CustomLayoutAreaView.swift Cited implementation, RunLoop, CustomLayoutAreaView, LayoutInfo, HandlePosition
AccessibilityUIExamples/Application/MainViewController.swift MainViewControllerDelegate, Cited implementation, MainViewController
AccessibilityUIExamples/Buttons/ButtonBaseViewController.swift ButtonBaseViewController
AccessibilityUIExamples/Application/SplitViewController.swift Cited implementation, SplitViewController
AccessibilityUIExamples/Buttons/CustomButtonView.swift DispatchQueue.main.asyncAfter, CustomButtonView
AccessibilityUIExamples/Application/Example.swift Foundation, Example
AccessibilityUIExamples/Stepper/ShaderTypes.h simd, Feature implementation
AccessibilityUIExamples/Text/CoreTextColumnView.swift CoreText, CoreTextColumnView, Columns
AccessibilityUIExamples/Application/DetailViewController.swift MediaLibrary, DetailViewController
AccessibilityUIExamples/Stepper/Shaders.metal metal_stdlib, Feature implementation
AccessibilityUIExamples/RadioButtons/CustomRadioButtonsView.swift RadioButtonAccessibilityElement, CustomRadioButtonsView, LayoutInfo
AccessibilityUIExamples/Stepper/CustomStepperView.swift CustomStepperView, LayoutInfo, BufferIndices
AccessibilityUIExamples/Switches/TwoPositionSwitchView.swift TwoPositionSwitchCell, TrackStates, TwoPositionSwitchView
AccessibilityUIExamples/Checkbox/CustomCheckBoxView.m CustomCheckBoxView
AccessibilityUIExamples/Checkbox/CustomCheckBoxView.swift CustomCheckBoxView, LayoutInfo