iOS Build a Simple iPhone App with Swift View Controllers and Views Creating IBOutlets

imelda cloutier
PRO
imelda cloutier
Pro Student 2,597 Points

funFactLabel.text bring error. value of type 'uiview' has no member text

help

2 Answers

Can I see your outlet? Your outlet for this label should be @IBOutlet weak var funFactLabel: UILabel! Your error is telling you that funFactLabel is assigned as a UIView, so when you try to assign text to the "label", it doesn't recognize it. If you have any questions, feel free to reply.

Good Luck, Arnav

alexander88
seal-mask
.a{fill-rule:evenodd;}techdegree
alexander88
UX Design Techdegree Student 8,989 Points

I'm having the same problem. I realized I didn't make my connection weak so I went and remade it (not sure if you have to go through the linking process shown of if you can just shortcut it and edit solely the code). It's still giving me problems though, saying:

Value of type 'UILabel' has no member 'txt'

This is the code I have currently:

''' import UIKit

class ViewController: UIViewController {

@IBOutlet weak var funFactLabel: UILabel!
override func viewDidLoad() {
    super.viewDidLoad()

   funFactLabel.txt = "Fun Fact!"
}

} '''

imelda cloutier
PRO
imelda cloutier
Pro Student 2,597 Points

found my answer on youtube. somehow my link from the label to the text disappeared. I just deleted the code and redo the linkage