This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { | |
switch manager.authorizationStatus() { | |
case .authorizedAlways: | |
print("Always authorized.") | |
case .authorizedWhenInUse: | |
print("Authorization granted only when app is in use.") | |
case .denied, .notDetermined, .restricted: | |
print("Not authorized.") | |
@unknown default: | |
print("Unknown.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if locationManager.accuracyAuthorization == .reducedAccuracy { | |
locationManager.requestTemporaryFullAccuracyAuthorization(withPurposeKey: "wantsToDeliverFoodToDoorStep") { (error) in | |
// Use location with full accuracy | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println("If Expression") | |
val a = 100 | |
val b = 200 | |
/** | |
* COMPILATION ERROR: 'if' must have both main and 'else' branches if used as an expression. | |
*/ | |
val maxValue = if (b > a) "b is greater" |