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
import Contacts | |
class CountryDetector { | |
func detectCountryWithoutLocation() -> String { | |
CNContactsUserDefaults.shared().countryCode | |
} | |
} |
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
import CoreTelephony | |
class CountryDetector { | |
var telephonyInfo = CTTelephonyNetworkInfo() | |
func detectCountryWithoutLocation() -> String? { | |
guard let provider = telephonyInfo.serviceSubscriberCellularProviders?.first(where: { $0.value.isoCountryCode != nil })?.value else { | |
return Locale.current.regionCode | |
} |
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
import CoreTelephony | |
class CountryDetector { | |
var telephonyInfo = CTTelephonyNetworkInfo() | |
func detectCountryWithoutLocation() -> String? { | |
guard let provider = telephonyInfo.serviceSubscriberCellularProviders?.first(where: { $0.value.isoCountryCode != nil })?.value else { | |
return nil | |
} |
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
alias ..="cd .." | |
alias gps="git push" | |
alias gpl="git pull" | |
alias gcom="git commit -m" | |
alias gcd="git checkout" | |
alias gs="git status" | |
alias gm="git merge" | |
alias gl="git log" | |
alias grem="gir remote -v" | |
alias gadd="git add " |
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
typealias HKSamplesResult = Result<[HKSample], Error> | |
func fetchAllBloodPressure(completion: @escaping (HKSamplesResult) -> ()) { | |
let correlationType = HKCorrelationType.correlationType(forIdentifier: .bloodPressure)! | |
let query = HKCorrelationQuery(type: correlationType, predicate: nil, samplePredicates: nil) { | |
(query, results, error) in | |
guard let correlations = results, error == nil else { | |
print("Error during the query: \(String(describing: error?.localizedDescription))") | |
completion(.failure(HKStoreManagerError.QueryExecutionError)) | |
return |
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
import UIKit | |
var str = "Hello, playground" | |
var a = 1 | |
var b = a | |
b = b + 1 | |
/// Value of `a` doesn't change when the value of `b` changed. This is the default behaviour of Value types | |
print(a) |
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
import Foundation | |
let formatter = NumberFormatter() | |
formatter.numberStyle = .currency | |
formatter.usesGroupingSeparator = true | |
formatter.locale = .current | |
formatter.minimumFractionDigits = 2 | |
formatter.maximumIntegerDigits = 8 | |
//formatter.negativeFormat = "¤ -#,##0.00" | |
//formatter.positiveFormat = "¤# ##0.00" |
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
import Foundation | |
let formatter = NumberFormatter() | |
formatter.numberStyle = .currency | |
formatter.usesGroupingSeparator = true | |
formatter.locale = .current | |
formatter.minimumFractionDigits = 2 | |
formatter.maximumIntegerDigits = 8 | |
let number = 100.2 as NSNumber |
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
class BloodPressureClassifier { | |
static func classifyBloodpessure(systolicValue: Int, diastoicValue: Int) -> BloodPressureClassification { | |
switch (systolicValue, diastoicValue) { | |
case (SystolicRanges.severeHyperTensionRange, _), (_, DiastolicRanges.severeHyperTensionRange): | |
return .severeHypertension | |
case (SystolicRanges.moderateHypertensionRange, _), (_, DiastolicRanges.moderateHypertensionRange): | |
return .moderateHypertension | |
case (SystolicRanges.mildHypertensionRange, _), (_, DiastolicRanges.mildHypertensionRange): |
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
class BloodPressureClassifier { | |
static func classifyBloodpessure(systolicValue: Int, diastoicValue: Int) -> BloodPressureClassification { | |
switch (systolicValue, diastoicValue) { | |
case (SystolicRanges.severeHyperTensionRange, _): | |
fallthrough | |
case (_, DiastolicRanges.severeHyperTensionRange): | |
return .severeHypertension | |
case (SystolicRanges.moderateHypertensionRange, _): |
NewerOlder