Interacting with nearby points of interest
At a glance
| Item | Summary |
|---|---|
| Purpose | Provide automatic search completions for a partial search query, search the map for relevant locations nearby, and retrieve details for selected points of interest. |
| App architecture | A Swift sample bundle with entry-bearing project variants PointsOfInterest-UIKit, PointsOfInterest, each leading to MapKit APIs. |
| Main patterns | View-controller organization, Protocol-oriented abstraction, Delegate or data-source callbacks, Service object, Binding-based state propagation, Actor-isolated state |
| Project style | 25 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
├── PointsOfInterest-UIKit/
│ ├── AppDelegate.swift
│ ├── BaseMapItemViewController.swift
│ ├── SearchResultsViewController.swift
│ ├── MapViewController.swift
│ ├── SceneDelegate.swift
│ └── SidebarViewController.swift
├── PointsOfInterest/
│ ├── PointsOfInterestApp.swift
│ ├── ContentView.swift
│ ├── MapModel.swift
│ ├── MapView.swift
│ └── NavigationModel.swift
└── Shared/
└── MapSearchConfiguration.swift
Structure observations
- Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
- Primary languages: Swift.
- The verified tree contains 7 project/configuration file(s) and 29 source declaration(s).
Overall architecture
flowchart LR
Bundle["Sample bundle"]
V1["PointsOfInterest-UIKit"]
V2["PointsOfInterest"]
Boundary["MapKit APIs"]
Bundle --> V1
V1 --> Boundary
Bundle --> V2
V2 --> Boundary
Reference code
PointsOfInterest-UIKit/AppDelegate.swift:10 — architecture anchor
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
}Interpretation
The branches represent separate entry-bearing project variants in the downloaded bundle, not runtime calls between those variants. Each branch is intentionally collapsed at the documented framework boundary; the detailed target-local flow remains in the cited files. Ownership is claimed only where the next section cites a stored property or assignment.
Ownership and state
classDiagram
Row *-- String : header
Row o-- MKMapItem : mapItem
Row o-- UICollectionViewDiffableDataSource : dataSource
Row o-- UICollectionView : collectionView
Ownership evidence
PointsOfInterest-UIKit/BaseMapItemViewController.swift:18 — stored dependency or nearest verified ownership anchor
var header: String?
var mapItem: MKMapItem?
init(header: String) {
self.header = header
}| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
Row |
String (header) |
owns value state | App/module collaborators |
Row |
MKMapItem (mapItem) |
stores or receives | App/module collaborators |
Row |
UICollectionViewDiffableDataSource (dataSource) |
stores or receives | App/module collaborators |
Row |
UICollectionView (collectionView) |
stores or receives | App/module collaborators |
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.
Class and protocol design
PointsOfInterest-UIKit/SearchResultsViewController.swift:178 — representative type boundary
protocol SearchResultsViewControllerDelegate: NSObjectProtocol {
/// The search results that `SearchResultsViewController` displays.
func searchResultsViewController(_ viewController: SearchResultsViewController, didUpdate searchResults: [MKMapItem])
/// The search results view controller calls this when the user selects a search result.
func searchResultsViewController(_ viewController: SearchResultsViewController, didSelect mapItem: MKMapItem)
}| Type | Responsibility | Depends on or conforms to |
|---|---|---|
AppDelegate |
Receives callback-driven events | UIResponder, UIApplicationDelegate |
PointsOfInterestApp |
Application entry and top-level composition | App |
SearchResultsViewControllerDelegate |
Defines a capability or collaboration contract | NSObjectProtocol |
BaseMapItemViewController |
View lifecycle, callbacks, and feature coordination | UIViewController |
SearchResultsViewController |
View lifecycle, callbacks, and feature coordination | BaseMapItemViewController |
MapViewController |
View lifecycle, callbacks, and feature coordination | UIViewController |
SceneDelegate |
Receives callback-driven events | UIResponder, UIWindowSceneDelegate |
SidebarViewController |
View lifecycle, callbacks, and feature coordination | BaseMapItemViewController |
ContentView |
User-interface presentation and input forwarding | View |
MapModel |
Feature data or observable state | Concrete collaborators/imported frameworks |
The source explicitly defines local protocol relationships: SidebarViewController → SearchResultsViewControllerDelegate.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
configureViewHierarchy (PointsOfInterest-UIKit/BaseMapItemViewController.swift:40) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
createLayout (PointsOfInterest-UIKit/BaseMapItemViewController.swift:46) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
configureDataSource (PointsOfInterest-UIKit/BaseMapItemViewController.swift:54) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: hide an implementation step that is not part of the collaboration surface. |
mapView (PointsOfInterest-UIKit/MapViewController.swift:15) |
private |
Use is restricted to the lexical declaration and same-file extensions allowed by Swift. | Inference: keep state mutation or dependency lifetime inside the owning implementation. |
Reference code
PointsOfInterest-UIKit/BaseMapItemViewController.swift:40 — representative boundary
private func configureViewHierarchy() {
collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: createLayout())
collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(collectionView)
}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 |
|---|---|---|
| Application entry and top-level composition | PointsOfInterestApp |
The source’s App suffix makes this role explicit. |
| View lifecycle, callbacks, and feature coordination | BaseMapItemViewController, MapViewController, SearchResultsViewController, SidebarViewController |
The source’s Controller suffix makes this role explicit. |
| Supplies data through a callback contract | SearchDataSource |
The source’s DataSource suffix makes this role explicit. |
| Receives callback-driven events | AppDelegate, SceneDelegate, SearchResultsViewControllerDelegate |
The source’s Delegate suffix makes this role explicit. |
| Feature data or observable state | MapModel, NavigationModel |
The source’s Model suffix makes this role explicit. |
| Framework-facing operations | LocationService |
The source’s Service suffix makes this role explicit. |
| User-interface presentation and input forwarding | ContentView, MapItemRowView, MapView, SearchCompletionItemView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| View-controller organization | PointsOfInterest-UIKit/BaseMapItemViewController.swift:12 |
A controller is the verified coordination boundary; this is MVC-style only where a separate model is present. |
| Protocol-oriented abstraction | PointsOfInterest-UIKit/SidebarViewController.swift:194 |
A local protocol and concrete conformance create an explicit capability boundary. |
| Delegate or data-source callbacks | PointsOfInterest-UIKit/AppDelegate.swift:11 |
Callback protocols invert event delivery back into the sample’s owner. |
| Service object | Shared/LocationService.swift:14 |
A role-named service contains framework-facing operations. |
| Binding-based state propagation | PointsOfInterest/SideBarListViewSection.swift:14 |
A binding exposes controlled read/write access while the upstream owner remains authoritative. |
| Actor-isolated state | PointsOfInterest-UIKit/SearchResultsViewController.swift:60 |
Actor annotations make the concurrency ownership boundary explicit. |
Naming conventions
- Types: App: PointsOfInterestApp; Controller: BaseMapItemViewController, MapViewController, SearchResultsViewController, SidebarViewController; DataSource: SearchDataSource; Delegate: AppDelegate, SceneDelegate, SearchResultsViewControllerDelegate; Model: MapModel, NavigationModel; Service: LocationService; View: ContentView, MapItemRowView, MapView, SearchCompletionItemView, SettingsView.
- Protocols:
SearchResultsViewControllerDelegate. - Methods:
viewDidLoad,configureViewHierarchy,createLayout,configureDataSource,updateCollectionViewSnapshot,configureHeaderCell,configureResultCell,presentMapItemDetail. - Files:
PointsOfInterest-UIKit/AppDelegate.swift,PointsOfInterest/PointsOfInterestApp.swift,PointsOfInterest-UIKit/BaseMapItemViewController.swift,PointsOfInterest-UIKit/SearchResultsViewController.swift,Shared/MapSearchConfiguration.swift,PointsOfInterest-UIKit/MapViewController.swift.
Architecture takeaways
AppDelegateis the main source-visible entry or composition anchor for this sample.- Framework work reaches MapKit, SwiftUI, UIKit, SwiftData 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 |
|---|---|
PointsOfInterest-UIKit/AppDelegate.swift |
AppDelegate |
PointsOfInterest/PointsOfInterestApp.swift |
PointsOfInterestApp |
PointsOfInterest-UIKit/BaseMapItemViewController.swift |
BaseMapItemViewController, Section, Row |
PointsOfInterest-UIKit/SearchResultsViewController.swift |
SearchResultsViewController, SearchResultsViewControllerDelegate |
Shared/MapSearchConfiguration.swift |
MapSearchConfiguration, RegionPriority, SearchResultType, PointOfInterestOptions, AddressOptions |
PointsOfInterest-UIKit/MapViewController.swift |
MapViewController |
PointsOfInterest-UIKit/SceneDelegate.swift |
SceneDelegate |
PointsOfInterest-UIKit/SidebarViewController.swift |
SidebarViewController |
PointsOfInterest/ContentView.swift |
ContentView |
PointsOfInterest/MapModel.swift |
MapModel |