I have a class1 which is having many variable and also having one function within a class1.I am calling the function from another class class2.function triggered but i cannot access variable of class1.
here is the sample code
class ViewController: UIViewController {
var Flat:String?
var Flong:String?
var Tlat:String?
var Tlong:String?
override func viewDidLoad() {
super.viewDidLoad()
Flat = "flat value";
Flong="flong value";
Tlat="Tlat value";
Tlong="tlong value";
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func calculation()
{
print("origin_lat new(Flat)")
print("origin_lng new(Flong)")
print("dest_lat new(Tlat)")
print("dest_lng new(Tlong)")
}
}
I am calling calculation method from another class Collectionviewcell click function
var mycontroller : ViewController = ViewController()
mycontroller.calculation()
Why i could not access the values anyone help me?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…