                 if let r = range {
                     inputTemp = curMajor.substringWithRange(r) //Since case may change
                     outputTemp = curMajor
-                    autoController.completeAutoSelection(curMajor)
+                    if let a = autoController { a.completeAutoSelection(curMajor) }
                     foundMatch = true
                     break
                 }

        if pEnabled && autoCompleteDictionary.count > 0 && UIDevice.currentDevice().userInterfaceIdiom != .Phone {
            self.addTarget(self, action: "displayPopover", forControlEvents: .EditingDidBegin)
            autoController = CGAutoCompleteViewController(selectables: autoCompleteDictionary)
            autoController.delegate = self
            autoPopController = UIPopoverController(contentViewController: autoController)
            if let a = autoPopController { a.popoverContentSize = autoController.view.frame.size }
        }
    }
    


public class CGAutoCompleteTextField: UITextField, CGAutoCompletePopoverDelegate {
    
    var autoController: CGAutoCompleteViewController?
    var autoPopController: UIPopoverController?
    var autoCompleteDictionary: [String]!
    
