0

In My project i have two file ViewController.swift and ButtonViewController.swift . In ViewController i have this code

var nomeLabel:String!
func goToView(sender: UIButton!) {
// self.performSegueWithIdentifier("goToView", sender: self) // I used This for Go to Second View in Another moment
var label: UILabel = UILabel()
label.frame = CGRectMake(self.view.frame.size.width/2, 10, 150, 21);
label.backgroundColor = UIColor.blackColor()
label.textColor = UIColor.whiteColor()
label.textAlignment = NSTextAlignment.Center
label.text = "\(self.nomeLabel)"
self.myView.addSubview(label)
})
}

and now I want to take the value of the variable self.nomeLabel in the second file ButtonViewController.swift. how can I view this variable in ButtonViewController.swift ?

8
  • 1
    Not clear enough. What is 'button.swift'? what is 'nomeLabel'? (I 'guess' a UILabel?). And this line: "import in the one Label on second file". What do you mean 'import in'? What is 'the one', what is 'the second'. Hard to figure what is it you're asking. In you code, there's a func that adds a label to some view. There's really not much there. Commented Nov 18, 2014 at 4:17
  • I edited my question, no one understood very well before. Commented Nov 18, 2014 at 8:35
  • Looks very similar to this other question (answered): stackoverflow.com/questions/24333142/… Commented Nov 18, 2014 at 9:47
  • Yes but class Main { var name:String init(name:String) { self.name = name } } var mainInstance = Main(name:"My Global Class") I can enter in the ViewController instead of creating the global.swift ? Commented Nov 18, 2014 at 9:51
  • I had seen this question but I'm sorry ,I'm not able to develop this with my example Commented Nov 18, 2014 at 10:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.