Does it help if I also file a bug?
Post
Replies
Boosts
Views
Activity
Thanks Claude, I re-read the section on Extensions and this is what it says at the top of that section:
Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you do not have access to the original source code (known as retroactive modeling). So Apple obviously has the source code, that's not why they're doing it. I see how each protocol is a separate extension, that makes sense to me too. But I also see that each operator is also an extension. How does that help?
That's very interesting, so you can actually put the UITextFieldDelegate code in it's own section of the file so it is all logically grouped together. I'll try that next time.
To answer my own question, use CMD-Enter.
Here is a simple view with 2 DatePickers:
import SwiftUI
extension Date {
var justDate: String {
let dateFormatter = DateFormatter()
dateFormatter.dateStyle = .long
dateFormatter.timeStyle = .none
return dateFormatter.string(from: self)
}
}
struct ContentView: View {
@State private var start = Date()
@State private var end = Date()
var body: some View {
List {
Section(header: Text("Select Dates")) {
DatePicker("Start date", selection: $start, displayedComponents: [.date])
DatePicker("End date", selection: $end, displayedComponents: [.date])
}
Section(header: Text("Date Values")) {
Text("Start: \(start.justDate)")
Text("End: \(end.justDate)")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
I recommend that you go through this tutorial, 100 Days of SwiftUI. He shows you exactly what to do in Xcode, which should help you get started.
https://www.hackingwithswift.com/100/swiftui