I recently watched a video tutorial on Lynda.com, and I noticed that the author declared several global variables that included two instances of the class. The main reason for my question is because I heard that we need to try to avoid using global variables if you really don't need them. I can see the use of global variables for NSUserDefaults' Keys, but I'm not sure about global instances.
Here is the code showing global variable declarations. I am only concerned about variables masterViewand detailViewController.
import UIKit
var objects:[String] = [String]()
var currentIndex:Int = 0
var masterView:MasterViewController?
var detailViewController:DetailViewController?
let kNotes:String = "notes"
let BLANK_NOTE:String = "(New Note)"
class MasterViewController: UITableViewController {
// class code
}
Is it possible to declare class instances as global variables?