프로그래밍 초보자입니다. 필자는 locationManager 함수에서 좌표를 가져와 Firebase에 연결할 수있는 방법을 찾으려고합니다. 계속 오류가 발생합니다 : 'CLLocation!'을 입력하십시오. 회원 '위도'가 없습니다.코어 위치 데이터 추출 후 Firebase에 업로드
locationManager 함수 외부에서 myLocation 변수 좌표를 가져 오는 방법을 알아 내려고 노력했습니다.
어떤 조언이 도움이 될 것입니다!
import UIKit
import Firebase
import CoreLocation
class SignupViewController: UIViewController,CLLocationManagerDelegate {
let manager = CLLocationManager()
let currentUserLocation = CLLocation!
override func viewDidLoad() {
super.viewDidLoad()
let cloud = Storage.storage().reference(forURL: "gs://applesandoranges.appspot.com")
ref = Database.database().reference()
userStorage = cloud.child("users")
manager.delegate = self
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations[0]
let myLocation = CLLocationCoordinate2DMake(location.coordinate.latitude, location.coordinate.longitude)
은}
}
정말 고마워요! CLLocation을 변경하기 위해 CLLocationCoordinate2D로 변경해야했습니다. –