// 位置請求這種事,最好不要產出一堆實例在程式碼中,最好一次集中管理就好 class LocationManager{ // 位置請求 func requestMyLocation(){ print("TW") }
}
// 每次都要實例化一次,我覺得不行 let myLocation = LocationManager() myLocation.requestMyLocation()
class LocationManager{
static let shared = LocationManager()
init(){}
func requestMyLocation(){
print("TW")
}
} // 實例化一次後,集中管理,我覺得可以 LocationManager.shared.requestMyLocation() //"TW"