Extentions: describing
This commit is contained in:
parent
8fe5a49f52
commit
705479c710
3 changed files with 8 additions and 2 deletions
|
|
@ -1,3 +1,9 @@
|
|||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
|
||||
extension Text {
|
||||
init(describing object: CustomStringConvertible){
|
||||
self.init(String(describing: object))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -8,8 +8,8 @@ struct TrainView: View {
|
|||
var train2 = Train(name: "RE1423", delay: 5){ Bike(name: "Bulls", color: "orange")}
|
||||
|
||||
var body: some View {
|
||||
Text(train.description)
|
||||
Text(train2.description)
|
||||
Text(describing: train)
|
||||
Text(describing: train2)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue