以前の書き方:
定義:
@Environment(\.presentationMode) private var presentationMode
使用:
presentationMode.wrappedValue.dismiss()
現在の書き方:
定義:
@Environment(\.dismiss) private var dismiss
使用:
dismiss()
以前の書き方:
定義:
@Environment(\.presentationMode) private var presentationMode
使用:
presentationMode.wrappedValue.dismiss()
現在の書き方:
定義:
@Environment(\.dismiss) private var dismiss
使用:
dismiss()
data class CustomDate( val year: Int, val month: Int, val day: Int ) : Comparable<CustomDate> { override fun compareTo(other: CustomDate): Int { return compareValuesBy(this, other, CustomDate::year, CustomDate::month, CustomDate::day) } override fun toString(): String { return "year: $year, month: $month, day: $day" } } fun main() { var custumDates = listOf( CustomDate(2023, 1, 1), CustomDate(2023, 1, 2), CustomDate(2023, 2, 1), CustomDate(2022, 1, 1), CustomDate(2022, 1, 2), CustomDate(2022, 2, 1) ) .shuffled() .sorted() for (customDate in custumDates) { println(customDate.toString()) } }
出力は:
year: 2022, month: 1, day: 1
year: 2022, month: 1, day: 2
year: 2022, month: 2, day: 1
year: 2023, month: 1, day: 1
year: 2023, month: 1, day: 2
year: 2023, month: 2, day: 1
data class CustomDate( val year: Int, val month: Int, val day: Int ) : Comparable<CustomDate> { override fun compareTo(other: CustomDate): Int { if (year == other.year) { if (month == other.month) { return day - other.day } else { return month - other.month } } else { return year - other.year } } override fun toString(): String { return "year: $year, month: $month, day: $day" } } fun main() { var custumDates = listOf( CustomDate(2023, 1, 1), CustomDate(2023, 1, 2), CustomDate(2023, 2, 1), CustomDate(2022, 1, 1), CustomDate(2022, 1, 2), CustomDate(2022, 2, 1) ) .shuffled() .sorted() for (customDate in custumDates) { println(customDate.toString()) } }
出力は:
year: 2022, month: 1, day: 1
year: 2022, month: 1, day: 2
year: 2022, month: 2, day: 1
year: 2023, month: 1, day: 1
year: 2023, month: 1, day: 2
year: 2023, month: 2, day: 1
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { if 条件 { return 高さ } else { return UITableView.automaticDimension } }
override func viewDidLoad() { ... self.overrideUserInterfaceStyle = .light }
上記コードだと、該当ViewControllerはずっとライトモードになる。逆に= .dark
にするとずっとダークモードになる。