Sharing Your Location to Find a Park
At a glance
| Item | Summary |
|---|---|
| Purpose | Ask for location access using a customizable location button. |
| App architecture | A C/Objective-C header, Objective-C, Swift sample bundle with entry-bearing project variants Park Finder (SwiftUI), Park Finder (UIKit), each leading to CoreLocation APIs. |
| Main patterns | View-controller organization, Delegate or data-source callbacks, Coordinator, Binding-based state propagation |
| Project style | 11 scanned source file(s) across C/Objective-C header, Objective-C, Swift, organized around ranked entry, type, and file boundaries. |
Project structure
Source bundle/
├── Park Finder (UIKit)/
│ └── Park Finder/
│ ├── main.m
│ ├── AppDelegate.h
│ ├── AppDelegate.m
│ ├── SceneDelegate.m
│ ├── ViewController.m
│ ├── SceneDelegate.h
│ └── ViewController.h
├── Park Finder (SwiftUI)/
│ └── Park Finder/
│ ├── ParkFinder.swift
│ ├── ContentView.swift
│ ├── Coordinator.swift
│ └── MapView.swift
└── Configuration/
└── SampleCode.xcconfig
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, Objective-C, Swift.
- The verified tree contains 8 project/configuration file(s) and 7 source declaration(s).
Overall architecture
flowchart LR
Bundle["Sample bundle"]
V1["Park Finder (SwiftUI)"]
V2["Park Finder (UIKit)"]
Boundary["CoreLocation APIs"]
Bundle --> V1
V1 --> Boundary
Bundle --> V2
V2 --> Boundary
Reference code
Park Finder (UIKit)/Park Finder/main.m:11 — architecture anchor
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
}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
ContentView *-- CLLocationManager : manager
Coordinator o-- MapView : parent
MapView o-- CLLocationManager : manager
MapView *-- MKMapView : map
Ownership evidence
Park Finder (SwiftUI)/Park Finder/ContentView.swift:13 — stored dependency or nearest verified ownership anchor
@State var manager = CLLocationManager()| Owner | Object or state | Relationship | Mutation authority |
|---|---|---|---|
ContentView |
CLLocationManager (manager) |
owns wrapper-managed state | App/module collaborators |
Coordinator |
MapView (parent) |
stores or receives | App/module collaborators |
MapView |
CLLocationManager (manager) |
borrows mutable state | The upstream binding owner is authoritative |
MapView |
MKMapView (map) |
creates and retains | 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.
Class and protocol design
Park Finder (UIKit)/Park Finder/AppDelegate.h:10 — representative type boundary
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@end| Type | Responsibility | Depends on or conforms to |
|---|---|---|
AppDelegate |
Receives callback-driven events | UIResponder, UIApplicationDelegate |
ContentView |
User-interface presentation and input forwarding | View |
Coordinator |
Cross-object flow or session coordination | NSObject, CLLocationManagerDelegate |
MapView |
User-interface presentation and input forwarding | UIViewRepresentable |
SceneDelegate |
Receives callback-driven events | UIResponder, UIWindowSceneDelegate |
ViewController |
View lifecycle, callbacks, and feature coordination | UIViewController, CLLocationManagerDelegate, MKMapViewDelegate |
ParkFinder |
Represents a feature value or composable behavior | App |
No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.
Access control
| Symbol | Access | Verified effect | Likely rationale |
|---|---|---|---|
addPins (Park Finder (SwiftUI)/Park Finder/Coordinator.swift:19) |
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. |
window (Park Finder (UIKit)/Park Finder/SceneDelegate.h:12) |
header-visible |
The declaration is exposed to translation units that import the header. | Inference: declare a contract needed by other Objective-C/C translation units. |
locationButton (Park Finder (UIKit)/Park Finder/ViewController.h:24) |
header-visible |
The declaration is exposed to translation units that import the header. | Inference: declare a contract needed by other Objective-C/C translation units. |
mapview (Park Finder (UIKit)/Park Finder/ViewController.h:25) |
header-visible |
The declaration is exposed to translation units that import the header. | Inference: declare a contract needed by other Objective-C/C translation units. |
Reference code
Park Finder (SwiftUI)/Park Finder/Coordinator.swift:19 — representative boundary
private func addPins(location: CLLocation) {
// ...
}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 | ViewController |
The source’s Controller suffix makes this role explicit. |
| Cross-object flow or session coordination | Coordinator |
The source’s Coordinator suffix makes this role explicit. |
| Receives callback-driven events | AppDelegate, SceneDelegate |
The source’s Delegate suffix makes this role explicit. |
| User-interface presentation and input forwarding | ContentView, MapView |
The source’s View suffix makes this role explicit. |
Design patterns
| Pattern | Source evidence | Purpose or tradeoff |
|---|---|---|
| View-controller organization | Park Finder (UIKit)/Park Finder/ViewController.h:21 |
A controller is the verified coordination boundary; this is MVC-style only where a separate model is present. |
| Delegate or data-source callbacks | Park Finder (SwiftUI)/Park Finder/Coordinator.swift:11 |
Callback protocols invert event delivery back into the sample’s owner. |
| Coordinator | Park Finder (SwiftUI)/Park Finder/Coordinator.swift:11 |
A role-named coordinator centralizes cross-object flow. |
| Binding-based state propagation | Park Finder (SwiftUI)/Park Finder/MapView.swift:13 |
A binding exposes controlled read/write access while the upstream owner remains authoritative. |
Naming conventions
- Types: Controller: ViewController; Coordinator: Coordinator; Delegate: AppDelegate, SceneDelegate; View: ContentView, MapView.
- Protocols: no local protocol declaration in the scanned source.
- Methods:
application,scene,sceneDidDisconnect,sceneDidBecomeActive,sceneWillResignActive,sceneWillEnterForeground,sceneDidEnterBackground,viewDidLoad. - Files:
Park Finder (SwiftUI)/Park Finder/ParkFinder.swift,Park Finder (UIKit)/Park Finder/AppDelegate.h,Park Finder (SwiftUI)/Park Finder/ContentView.swift,Park Finder (UIKit)/Park Finder/AppDelegate.m,Park Finder (UIKit)/Park Finder/SceneDelegate.m,Park Finder (UIKit)/Park Finder/ViewController.m.
Architecture takeaways
mainis the main source-visible entry or composition anchor for this sample.- Framework work reaches UIKit, CoreLocation, MapKit, SwiftUI 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.
- The source does not justify labeling the design protocol-oriented.
Source map
| Source file | Relevant symbols |
|---|---|
Park Finder (UIKit)/Park Finder/main.m |
Feature implementation |
Park Finder (SwiftUI)/Park Finder/ParkFinder.swift |
ParkFinder |
Park Finder (UIKit)/Park Finder/AppDelegate.h |
AppDelegate |
Park Finder (SwiftUI)/Park Finder/ContentView.swift |
ContentView, ContentView_Previews |
Park Finder (UIKit)/Park Finder/AppDelegate.m |
AppDelegate, AppDelegate |
Park Finder (UIKit)/Park Finder/SceneDelegate.m |
SceneDelegate, SceneDelegate |
Park Finder (UIKit)/Park Finder/ViewController.m |
ViewController, ViewController |
Park Finder (SwiftUI)/Park Finder/Coordinator.swift |
Coordinator |
Park Finder (SwiftUI)/Park Finder/MapView.swift |
MapView |
Park Finder (UIKit)/Park Finder/SceneDelegate.h |
SceneDelegate |