1

The following is a simplified version of some code I am trying to get to work.

The problem I have is that the function inside the struct cannot see the textFields.

I have the error message: Swift compiler error: 'ViewController.Type does not have a member called textField01'

I have done some searching and tried some solutions, but nothing seems to work.

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var textField01: UITextField!
@IBOutlet weak var textField02: UITextField!
@IBOutlet weak var textField03: UITextField!

struct LineData {

    var line: String
    var speed: String
    var format: String

    func updateTBs() {

        textField01.text = line
        textField02.text = speed
        textField03.text = format

        }
}


let x1LineData = LineData (

    line: "x1",
    speed: "8000",
    format: "7500"

    )

let x2LineData = LineData (

    line: "x2",
    speed: "12000",
    format: "1000"

    )



@IBAction func dataButton01(sender: AnyObject) {

    x1LineData.updateTBs()

}

@IBAction func dataButton02(sender: AnyObject) {

    x2LineData.updateTBs()

}

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}
}
Kendel
  • 1,698
  • 2
  • 17
  • 33
Paul
  • 11
  • 4
  • In Swift, an instance of an inner type (LineData) does not have access to the properties of the outer type (ViewController). – Martin R Sep 13 '15 at 15:46

0 Answers0