0

i have this Class in my ViewController.swift for example ...

class Person {
internal let name: String
init(name: String) {
self.name = name
}
}
class ViewController: UIViewController {
}

and in my SecondViewController i have

 override func viewDidLoad() {
 super.viewDidLoad()
 let person = Person(name: "")
 println(person.name) 
 }

How can I assign a value a name from the internal of the view controller class ?

Massimo Negro
  • 65
  • 1
  • 8
  • This is the 3rd time you are posting this question [1st](http://stackoverflow.com/questions/26980929/swift-take-a-variable-in-second-file-buttonviewcontroller-swift) [2nd](http://stackoverflow.com/questions/27048766/swift-access-controll-example). I realize now that I tried to answer myself on your 2nd one, but you are not giving enough details to figure out what you are really asking – Antonio Nov 21 '14 at 23:07
  • i want simply assign a value to a name from my Class ViewController .please – Massimo Negro Nov 21 '14 at 23:09

2 Answers2

0

Just create an instance of it:

var person = Person(name: "Person Name")

I don't know what you are going to do with it - it can be either a local variable in a view controller method, or a view controller property.

Antonio
  • 71,651
  • 11
  • 148
  • 165
0

You can use this to create an instance and it's name property

var personsName = Person(name: "persons name")