*Consolidation Entry* Basic App 2
Just a quick addition to the 'basic' Buffy app I made. This is purely to show some other functionality and avoid the whole connecting each button to a separate view issue. It also will add the 'random' element.
Basically, rather than a character coming up with the appropriate button, I want a 'random' character selection. This can be broken down to regulars, guest stars and one offs, thinking about it. Neat!
The random element will use the Int.random method, with arrays created of each character, using the buffyCharacter struct. You seem, I'm talking more like a coder! I don't know if I can 'save as' so I don't lose the option of what I already have...
No, apparently not but no bother. It would be easy to get this back to that anyway. So I'm going to create an example just with another character to see if that works.
Got it working! Nowhere near as simple and actually couldn't just put all of the characters into an array into a struct. That's something to do for another time. Instead, I made an array in the VC for the character display and have got the random number generator, and option to display each character's name, picture and bio. So it works! Clunky and not ideal but yes, got the idea of this now.
I could do the same with additional VCs - one for the recurring and one for one offs - not loads of extra screens needed (just two essentially). Again, there could be a better way to do that, but I have a good basis for an app here.
So I have done one more VC, fiddled around with all the views and constraints - definitely much prefer SwiftUI for that!
They main thing is it works. I could easily add the 'One off' VC and then replicate the code. My 'code smell' is taking off as I have repeated code, which is never ideal. So I know that it could all be a lot smoother. But it does work and I'm proud of developing this further and making something that is decent and is much better than just the press a button to get info on one character at a time. So good stuff!
Comments
Post a Comment