Building Failing with Error "Value of type 'UITextField?' has no member 'stringValue'"

I am new to coding and swift (hopefully I'm in the right category)
Anyway I followed a tutorial on building a MacOS app here,

It worked but I don't really want to build of MacOS (yet, at least) so I am trying to recreate the app for iPhone XR, I got everything set up but I am receiving an error,

Value of type 'UITextField?' has no member 'stringValue'

Here is a copy of the code I have;

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var nameField: UITextField!
    @IBOutlet weak var helloLabel: UITextView!
    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.

    @IBAction func sayButtonClicked(_ sender: Any) {
        var name = nameField.stringValue
        if name.isEmpty {
            name = "World!"
        let greeting = "Hello \(name)! Polar bears are marines mammals, and spend much of their time on Artic sea ice. Did you know that \(name)? Although, I am an iPhone with Siri, I was not aware of that. Yay, Polar bears!"
        helloLabel.stringValue = greeting

Hi @HeadlineINeed!

You might have more luck asking iOS-specific questions on the Apple Developer Forums, but to answer your question here, UITextField is slightly different from NSTextField on macOS. NSTextField exposes a stringValue property, but UITextField exposes a text property.

The line should read:

helloLabel.text = greeting
Terms of Service

Privacy Policy

Cookie Policy