I've been building Swift apps where basically all the functionality is in the ViewController. I know this isn't the optimal way to do it because design patterns help you expand the app but I don't really understand them. I keep reading articles about splitting up the Model, View and Controller but the articles don't give me answers on how to do it.
Currently I'm building an app. I've made all the functions in the ViewController again but I've split the functions up between the three sections.
My whole app is split up like this:
//Model
func stopMonitoring(_ song:Song) {
for region in locationManager.monitoredRegions {
guard let circularRegion = region as? CLCircularRegion, circularRegion.identifier == song.identifier else { continue }
locationManager.stopMonitoring(for: circularRegion)
}
}
//View
func addToView(_ song:Song){
mapView.addAnnotation(song)
mapView.add(MKCircle(center: song.coordinate, radius: song.radius))
}
How do I go about turning this into a Model-View-Controller design?
My thoughts have been to make separate classes of each and have them always loading but I have variables in the controller class that I use in them all which seems like it wouldn't be an efficient way to go about things. I've also heard about sharedinstances but again don't know how they come into play.