import UIKit
var saves: [Int?] = [nil, nil, nil, nil];
class SaveViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBOutlet weak var saveText1: UITextView!
@IBOutlet weak var saveText2: UITextView!
@IBOutlet weak var saveText3: UITextView!
@IBOutlet weak var saveText4: UITextView!
@IBOutlet weak var saveImageView1: UIImageView!
@IBOutlet weak var saveImageView2: UIImageView!
@IBOutlet weak var saveImageView3: UIImageView!
@IBOutlet weak var saveImageView4: UIImageView!
override func viewDidLoad() {
saveText1.addGestureRecognizer(TGR("save1"))
saveText2.addGestureRecognizer(TGR("save2"))
saveText3.addGestureRecognizer(TGR("save3"))
saveText4.addGestureRecognizer(TGR("save4"))
unwrapAll()
}
func TGR(name:String) -> UITapGestureRecognizer {
return UITapGestureRecognizer(target: self, action: Selector(name))
}
func unwrapAll() {
unwrap1()
unwrap2()
unwrap3()
unwrap4()
}
func unwrap1(){
if let n = saves[0] {
let source1 = data[n]
if let bgStr = source1["bg"] {
saveImageView1.image = UIImage(named: bgStr)
}
if let words = source1["words"] {
saveText1.text = words
}
}
}
func unwrap2(){
if let n = saves[1] {
let source2 = data[n]
if let bgStr = source2["bg"] {
saveImageView2.image = UIImage(named: bgStr)
}
if let words = source2["words"] {
saveText2.text = words
}
}
}
func unwrap3(){
if let n = saves[2] {
let source3 = data[n]
if let bgStr = source3["bg"] {
saveImageView3.image = UIImage(named: bgStr)
}
if let words = source3["words"] {
saveText3.text = words
}
}
}
func unwrap4(){
if let n = saves[3] {
let source4 = data[n]
if let bgStr = source4["bg"] {
saveImageView4.image = UIImage(named: bgStr)
}
if let words = source4["words"] {
saveText4.text = words
}
}
}
func save1(){
saves[0] = number
unwrap1()
}
func save2(){
saves[1] = number
unwrap2()
}
func save3(){
saves[2] = number
unwrap3()
}
func save4(){
saves[3] = number
unwrap4()
}
}