我的代码如下打印结构体数据。我只想打印没有结构名称的结构数据。我怎样才能做到这一点?另请参阅下面的图片。如何从打印结构中删除结构体名称(swift4)
var contacts = [Person]()
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func press(_ sender: Any) {
contacts.append(Person(name: a.text!, phone: Int(c.text!)!))
print(self.contacts.description)
label.text = self.contacts.description
}
struct Person {
var name: String
var phone: Int
}}
而不是张贴同一问题的多个问题。你应该仔细阅读,并在你之前的问题已经提供的答案上加倍注意。 –
顺便说一句,你仍然使用整数的电话号码,无论有多少人警告你。将其更改为字符串! - –