아주 기본적인 질문 덕분에 UILabel.text을 변경 할 수 있도록 미래에 변경/firstName.text = "Joe Bloggs"를 명시 적으로 선언하는 것보다 더 많은 이름/레이블을 추가하십시오초급 스위프트 - 문제 객체 (jName)에 저장된 속성을 참조하여 UILabel의 텍스트를 변경하려고 객체에 저장된 속성에 도움</p> <p>에 대한
jName의 저장된 속성으로 텍스트를 변경할 수없는 이유를 이해하지 못합니까? 나는 속성을 초기화하려고했지만 이것 역시 도움이되지 않았습니다. 누구든지 이것을 구조화하는 가장 좋은 방법을 알고 있습니까?
class ViewController: UIViewController {
@IBOutlet var firstName: UILabel!
@IBOutlet var thirdName: UILabel!
struct jName {
var fName: String = "Joe"
var lName: String = "Blogs"
init(fName: String, lName: String) {
self.fName = fName
self.lName = lName
}
}
override func viewDidLoad() {
super.viewDidLoad()
assignLabels()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func assignLabels() {
firstName.text = jName.fName
thirdName.text = jName.lName
}
}