Posts

Post marked as solved
2 Replies
1.8k Views
Hello,I am new using NSCoding protocol. I understand how it works, but I don't know how to save and load the data. I've tried with NSKeyedArchiver.archiveRootObject(_:toFile:) and NSKeyedUnarchiver.unarchiveObject(withFile:), but I get a warning saying that they were deprecated. What method should I use?Thank you!
Posted Last updated
.
Post not yet marked as solved
2 Replies
469 Views
Hello,I have a Table View Controller with a custom Header, customized in this function:override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { let shopHeader = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.size.width, height: 70)) shopHeader.backgroundColor = UIColor(red: 209/255, green: 226/255, blue: 254/255, alpha: 1) let backShop = UIButton(frame: CGRect(x: 10, y: 20, width: 90, height: 30)) backShop.setTitle("< back", for: .normal) backShop.setTitleColor(UIColor.black, for: .normal) backShop.titleLabel?.font = UIFont(name: "Jack Armstrong", size: 20) backShop.addTarget(self, action: #selector(pressed), for: .touchUpInside) shopHeader.addSubview(backShop) coins = UILabel(frame: CGRect(x: tableView.frame.size.width - 280, y: 20, width: 200, height: 30)) coins.text = String(UserDefaults.standard.integer(forKey: "Total")) coins.font = UIFont(name: "Jack Armstrong", size: 17) coins.textAlignment = NSTextAlignment.right shopHeader.addSubview(coins) return shopHeader }where coins is a global var. I have another function which job is change the text of the UILabel coins, but when I call this function the text doesn't change. What am I doing wrong? Is it mutable the Header of a TableView once it's loaded?
Posted Last updated
.
Post not yet marked as solved
3 Replies
296 Views
Hello,I've created an UIButton in the playground. Now I want to hide this button from the GameScene. How can I do it?
Posted Last updated
.
Post marked as solved
1 Replies
617 Views
Hi! I'm trying to connect GameScene.swift to GameViewController.swift.In GameScene I have this function:func pause() { }That works correctly and the game gets paused.Then, in my View Controller, I added a button of pause. What I want is to call pause() when the button is pressed. I tried adding this to the GameViewController.swift:@IBOutlet var PauseButton: UIButton! @IBAction func PauseButton(_ sender: UIButton) { let gameScene = GameScene() gameScene.pause() }But it doesn't do anything when I press the button. The Outlet and the Action are connected well and everything else in the game works good.Could anyone help me?Thank you!Ivet
Posted Last updated
.