Skip to content

Commit

Permalink
Chore:wrench:: #32 Modify ObservedObject
Browse files Browse the repository at this point in the history
- locationManager를 StateObject와 EnvrionmentObject를 사용하는 방식으로 변경
  • Loading branch information
taek0622 committed Jun 13, 2023
1 parent e5e998e commit 0f2007e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Nav/View/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import MapKit
import SwiftUI
struct MapView: View {
@ObservedObject var locationManager = LocationManager()
@StateObject var locationManager = LocationManager()

// 서울 좌표
@State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.5666791, longitude: 126.9782914), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
Expand All @@ -22,7 +22,8 @@ struct MapView: View {
annotationItems: mockDatas) {
data in MapMarker(coordinate: data.coordinate)
}
SearchedView(locationManager: locationManager, region: $region)
SearchedView(region: $region)
.environmentObject(locationManager)
}
.navigationTitle("NAV")
.searchable(
Expand All @@ -35,7 +36,7 @@ struct MapView: View {
}

private struct SearchedView: View {
let locationManager: LocationManager
@EnvironmentObject var locationManager: LocationManager
@Binding var region: MKCoordinateRegion
@Environment(\.isSearching) private var isSearching
@Environment(\.dismissSearch) private var dismissSearch
Expand Down

0 comments on commit 0f2007e

Please sign in to comment.