RW.com: Storyboards Segues Article - Part 2
Yes I'm back on the same day! One good thing about 'distancing' is having genuinely more time to code. Limiting in lots of other ways but every cloud and all that... So back on with the article - second and final part! Then a practical play around...
Start Time - 13:20
Same article as before -
https://www.raywenderlich.com/5055396-ios-storyboards-segues-and-more#toc-anchor-010
We're up to 'Selecting the Game'
So for this, we have another 'unwind segue'. The exit bit now works after the game is selected, but nothing actually is selected.

Here is what we're actually selecting.
Right more fancy code added! Various bits about the GamePicker. Needing the identifier to match up to something or other. Again, I'm sure this is a lot easier in SwiftUI.
This was specifically to get the checkmark in -
Start Time - 13:20
Same article as before -
https://www.raywenderlich.com/5055396-ios-storyboards-segues-and-more#toc-anchor-010
We're up to 'Selecting the Game'
So for this, we have another 'unwind segue'. The exit bit now works after the game is selected, but nothing actually is selected.

Here is what we're actually selecting.
Right more fancy code added! Various bits about the GamePicker. Needing the identifier to match up to something or other. Again, I'm sure this is a lot easier in SwiftUI.
This was specifically to get the checkmark in -
if indexPath.row == gamesDataSource.selectedGameIndex {
cell.accessoryType = .checkmark
} else {
cell.accessoryType = .none
}
Then all of the below added. That was to have rows selected/deselected...
extension GamePickerViewController {
override func tableView(
_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath
) {
// 1
tableView.deselectRow(at: indexPath, animated: true)
// 2
if let index = gamesDataSource.selectedGameIndex {
let cell = tableView.cellForRow(at: IndexPath(row: index, section: 0))
cell?.accessoryType = .none
}
// 3
gamesDataSource.selectGame(at: indexPath)
// 4
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .checkmark
}
}
More code added. At the moment, checkmark is going with newly selected game but it doesn't update.
OK just wasted a good 10 minutes on something that was not clear plus a few minutes break! All sorted now.
More bits of code added to get a player name saved...
Awesome! Only thing is that the star rating is one by default...
First Responders - this is quite subtle. It enables you to automatically start typing on the text field, rather than having to click on it! That is actually very clever.
There's a bit about the init and deinit I need to look over again - running out of time now!
A final cool thing. Selecting multiple views on the storyboard, then going on editor and selecting refactor to storyboard. That saves these as a new, separate storyboard!
Building and running still runs as before.
Finish Time - 2:00 (approx 30 minutes)
So this second part was definitely a bit rushed, but what interesting stuff! In my next entry - maybe even later on today - I am definitely going to play around with the code, trying to break down each part in more detail. Even if it's not so relevant in SwiftUI, it would be great to understand what's behind it more.
Comments
Post a Comment