Day17
今天是中秋節的前天~
來個容易的編碼連結與定義~
我們可以看到編碼前段,定義了類型的UI,像第二頁的7項欄子與相對的資料。
編碼
import UIKit
import RealmSwift
import Foundation
class ViewController: UIViewController {
@IBOutlet weak var AC: UITextField!
@IBOutlet weak var pas: UITextField!
@IBOutlet weak var namename: UITextField!
@IBOutlet weak var bd: UITextField!
@IBOutlet weak var em: UITextField!
@IBOutlet weak var pm: UITextField!
@IBOutlet weak var idm: UITextField!
@IBOutlet weak var update: UIButton!
var myButton = UIButton()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func upup(_ sender: UIButton) {
let realm = try! Realm()
let order = Order()
order.account = AC.text!
order.password = pas.text!
order.name = namename.text!
order.birthday = bd.text!
order.email = em.text!
order.phonenumber = pm.text!
order.id = idm.text!
try! realm.write{realm.add(order)}
print("fileURL: \(realm.configuration.fileURL!)")
}
@IBAction func jumptotwo(_ sender: UIButton) {
self.performSegue(withIdentifier: "segun_two", sender: self)
}
@IBAction func jumptosc(_ sender: UIButton) {
self.performSegue(withIdentifier: "segun_SC", sender: self)
}
}