UIView is available as a separate file. How can I pass data between two files without a segue?
I am trying to pass data without using segue. I am using UIView in main viewcontroller. This UIView has a separate file. I want to transfer the data to that file and assign it to the variable.
import UIKit
import Parse
class HesapView: UIView {
@IBOutlet weak var bakiyeLabel: UILabel!
@IBOutlet weak var bakiyeTLabel: UILabel!
@IBOutlet weak var ibanOrKartLabel: UILabel!
@IBOutlet weak var ayrintiButton: UIButton!
@IBOutlet weak var segmentControl: UISegmentedControl!
@IBAction func buttonTapped(_ sender: Any) {
switch segmentControl.selectedSegmentIndex {
case 0:
print("hesap")
case 1 :
print("kart")
default:
break
}
}
@IBAction func segmentControlTapped(_ sender: Any) {
switch segmentControl.selectedSegmentIndex {
case 0:
bakiyeLabel.text = "Kullanılabilir Bakiye"
bakiyeTLabel.text = "\(AnasayfaVC().anaHesapBakiye) ₺"
ibanOrKartLabel.text = "TR26 0000 0000 0000 0000 0050 01"
ayrintiButton.setTitle("Tüm Hesaplar >", for: .normal)
case 1 :
bakiyeLabel.text = "Kullanılabilir Limit"
bakiyeTLabel.text = "\(AnasayfaVC().anaKartLimit) ₺"
ibanOrKartLabel.text = "Kart Numarası: 2600 0000 0000 0001"
ayrintiButton.setTitle("Tüm Kartlar >", for: .normal)
default:
break
}
}
I want to show the retrieved data in UIView.
func getDataParseFromSegmentView() {
let hesapQuery = PFQuery(className: "Hesaplar")
hesapQuery.whereKey("objectId", equalTo: "3gBzkj3Bk1")
hesapQuery.findObjectsInBackground { objects, error in
if error != nil {
self.alertYolla(titleInput: "Hata", messageInput: error?.localizedDescription ?? "Hata Oluştu.")
} else {
if objects != nil {
for object in objects! {
if let hesapAdi = object.objectId {
self.anaHesap = hesapAdi
}
if let hesapBakiye = object.object(forKey: "bakiye") as? String {
self.anaHesapBakiye = hesapBakiye
}
if let hesapIBAN = object.object(forKey: "hesapNo") as? String {
self.anaHesapIBAN = hesapIBAN
}
}
}
}
}
let kartQuery = PFQuery(className: "Kartlar")
kartQuery.whereKey("kartNo", equalTo: "5026722530589834")
kartQuery.findObjectsInBackground { objects, error in
if error != nil {
self.alertYolla(titleInput: "Hata", messageInput: error?.localizedDescription ?? "Hata Oluştu.")
} else {
if objects != nil {
for object in objects! {
if let kartNo = object.object(forKey: "kartNo") as? String {
self.anaKartNo = kartNo
}
if let kartLimit = object.object(forKey: "kalanLimit") as? String {
self.anaKartLimit = kartLimit
}
if let kartID = object.objectId {
self.anaKartID = kartID
}
}
}
}
}
}
I tried assigning the file to the variable but without success.
let iuView = UIView()
iuView.variable1 = variable2
------------------------------
UIView
texField.text = variable1
I tried to do like the example above, it didn't work.