I built a custom keyboard extension for iOS. I initially built it using storyboards and - long story short - it didn't work that great, as there's a lot of glitching and crashes that happen when making keyboards with storyboards. So, I rebuilt it programmatically.
I'm 95% of the way in replicating the whole thing programmatically, but the key component doesn't work - a very important PickerView.
In the storyboard version of the app, the PickerView was a global variable, that several different functions could manipulate. It worked great!
Now, however, I've replicated the entire app programmatically. All the buttons, views, etc etc, are working great. However, the keyboard crashes when the PickerView is declared as a global variable. I thought I should just make it a local variable on my @objc func setupPickerView
, but realized the other functions (which need to be manipulated by other functions) wouldn't be able to manipulate it.
The only difference with the code (other than the programmatic layout) is :
@IBOutlet weak var timerPicker: UIPickerView!
var timerPicker: UIPickerView!
I've been reading up and seeing a lot about never using global variables, so I get that. But what I want to know is - what am I missing here? How should I look about fixing this? Do I need to take a step back and refactor everything, or could I be missing something simple?
Add to this that I'm a self-taught novice, and debugging an extension is very very difficult, and I could use some guidance. Thanks!