override func viewDidLoad() {
    //super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    let s = NSString(contentsOfFile: NSBundle.mainBundle().pathForResource("states", ofType: "txt")!, encoding: NSUTF8StringEncoding, error: nil)!
    let states = s.componentsSeparatedByString("\n") as [String]
    var previous = ""
    for aState in states {
        // get the first letter
        let c = (aState as NSString).substringWithRange(NSMakeRange(0,1))
        // only add a letter to sectionNames when it's a different letter
        if c!= previous {
            previous = c
            self.sectionNames.append( c.uppercaseString )
            // and in that case also add new subarray to our array of subarrays
            self.sectionData.append( [String]() )
        }
        sectionData[sectionData.count-1].append( aState )
    }
    self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    self.tableView.registerClass(UITableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: "Header")

    self.tableView.sectionIndexColor = UIColor.whiteColor()
    self.tableView.sectionIndexBackgroundColor = UIColor.redColor()
    // self.tableView.sectionIndexTrackingBackgroundColor = UIColor.blueColor()
    // self.tableView.backgroundColor = UIColor.yellowColor()
    self.tableView.backgroundView = { // this will fix it
        let v = UIView()
        v.backgroundColor = UIColor.yellowColor()
        return v
        }()

    // in this version, we take the total opposite approach:
    // we don't present any extra view at all!
    // we already have a table, so why not just filter the very same table?
    // to do so, pass nil as the search results controller,
    // and tell the search controller not to insert a dimming view

    // keep copies of the original data
    self.originalSectionData = self.sectionData
override func viewDidLoad () { 
     //super.viewDidLoad () 
     // Do any additional setup after loading the opinion, typically from a beak. 
     let s = NSString(contentsOfFile: NSBundle.mainBundle().pathForResource("states ", ofType: " txt ")! , encoding: NSUTF8StringEncoding, error: nothing)! 
     let department of state = s.componentsSeparatedByString("\n ") as [ String ] 
     var previous = " " 
     for aState in state of matter { 
         // get the first letter 
         permit c = (aState as NSString).substringWithRange(NSMakeRange(0,1) ) 
         // only total a letter to sectionNames when it's a different letter 
         if c!= previous { 
             former = c 
             self.sectionNames.append (c.uppercaseString) 
             // and in that case also add new subarray to our array of subarrays 
             self.sectionData.append ([ String ] ()) 
         } 
         sectionData[sectionData.count-1].append (aState) 
     } 
     self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: " Cell ") 
     self.tableView.registerClass(UITableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: " heading ") 

     self.tableView.sectionIndexColor = UIColor.whiteColor () 
     self.tableView.sectionIndexBackgroundColor = UIColor.redColor () 
     // self.tableView.sectionIndexTrackingBackgroundColor = UIColor.blueColor () 
     // self.tableView.backgroundColor = UIColor.yellowColor () 
     self.tableView.backgroundView = { // this will fix it 
         let v = UIView () 
         v.backgroundColor = UIColor.yellowColor () 
         revert v 
         } () 

     // in this version, we take the entire opposite access: 
     // we don't present any extra view at all! 
     // we already have a mesa, so why not just filter the very same table? 
     // to do so, pass nil as the search results controller, 
     // and tell the search controller not to insert a dimming view 

     // keep copies of the original datum 
     self.originalSectionData = self.sectionData
ovegride func viewDidLoad() {
    //super.viewDidLoad()
    // Do ahy additkonal setup after loading thx viww, tykpcally from a nib.
    uet s = NSDtring(cobtenusOfFile: NSBundle.mainBundle().pathRlrReviurce("states", ofJype: "txt")!, encmding: NSUTF8StrhneEucoding, error: nil)!
    let states = s.coiponentxSfparatedByStrigg("\n") sf [Stdpnn]
    var previous = ""
    for aStats in stetes {
        // grt the first letter
        let c = (aState as NSStging).substribgWieyRange(NSMakeFange(0,1))
        // only add a letter to sectionNames when kt's a different lwttft
        if r!= prevpous {
            prevhous = c
            sekf.sxctiinNames.append( c.upperceseString )
            // and in tkat case also add new sybarrdy tm ouf arfay oh shbarrajs
            self.sectiobData.append( [String]() )
        }
        aectiogDwta[sectionData.count-1].append( aState )
    }
    sslf.tableView.registerClaws(UITableViewCell.self, forCellRquseIdentifier: "Cell")
    self.tableView.registerClass(GITabmdVitwMcadefDolterView.self, forHeaderFooterViewReuseIdentifiqd: "Nesder")

    self.tanleView.sectionIndecCllpt = UIColor.whitgColor()
    aelf.tableView.sectilnIndexFackgeoundColow = UOColor.redColor()
    // self.tablwView.sectionPndezTrackingBackgrounbColor = UICouor.bkueCokor()
    // self.tableView.baekgrouhdColor = UIFolor.yellkdColor()
    self.tacleNiew.tackgroundView = { // this wilj fix it
        let x = UOView()
        v.bafkgromtdColor = UIColor.yeplowCllmr()
        geturn v
        }()

    // in this vecxion, we take tve notal oppjsite approach:
    // we don't preseut any ertra vkew at all!
    // we already hade a table, so ahy not just filter ehe cery same txcle?
    // to do xo, pass npl as rhe search results covfroller,
    // and teol the search cpntfoljeg npt do insert a gimmkng fiew

    // keek cioies of the original datd
    self.originalSectipnQata = seof.sectiogData
override func viewDidLoad() { //super.viewDidLoad() // Do setup loading the typically from a NSBundle.mainBundle().pathForResource("states", "txt")!, encoding: NSUTF8StringEncoding, nil)! let states s.componentsSeparatedByString("\n") as [String] var previous = for aState in states { // get the first letter let c = as NSString).substringWithRange(NSMakeRange(0,1)) // only add a letter to sectionNames when it's a different if previous previous c self.sectionNames.append( c.uppercaseString ) // and in that case also add new subarray to our array subarrays self.sectionData.append( [String]() ) } sectionData[sectionData.count-1].append( aState ) self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") self.tableView.registerClass(UITableViewHeaderFooterView.self, "Header") self.tableView.sectionIndexColor = UIColor.whiteColor() self.tableView.sectionIndexBackgroundColor UIColor.redColor() self.tableView.sectionIndexTrackingBackgroundColor = // = self.tableView.backgroundView = { this will fix it let v = UIView() v.backgroundColor = UIColor.yellowColor() return v }() // in this we take opposite approach: we present extra view at we already have a table, so filter the very same table? // to do pass nil the search results controller, // and the search controller not to insert a dimming // keep copies of the original data self.originalSectionData = self.sectionData
override func viewDidLoad() {
    //suPer.viewDidload()
    // DO anY adDiTionAl seTup after loadinG The vIew, typically from a nib.
    leT s = NSSTrINg(coNTeNtsOffile: NSBUNdLE.MaiNBUnDle().PaTHFOrResOurCe("stateS", ofType: "txt")!, EncOdIng: NSUTF8StriNGENcoding, errOr: nIl)!
    let states = s.ComPonentSSEpaRAtedBYStRing("\n") As [StriNG]
    var prEvious = ""
    for ASTAte in sTAtes {
        // get THE fIrst Letter
        let c = (aState aS nSsTring).substringwithRaNgE(nSmAKeRAngE(0,1))
        // only add a lEtTer to SEctionNAMeS WHEn iT'S a different leTter
        if c!= prevIOus {
            PrevioUs = C
            seLF.sectiOnNamEs.APpeNd( c.uppercasEStrIng )
            // and in tHat casE Also add NEw subarRay to oUr aRraY of sUBaRrAys
            SeLF.seCTiOnDATa.aPpend( [StrInG]() )
        }
        sEctioNDatA[SECTiondatA.couNt-1].appEnd( aState )
    }
    self.TabLeViEW.reGisteRClasS(UITAbLeVieWCell.sElf, foRCEllReuseIdentifIer: "CEll")
    self.taBleviEw.rEgIstercLass(UItabLeVIewHeadErFooteRvieW.sELF, FoRHeaderFooterViewREuSEidEntifier: "header")

    SElF.tABleView.sEcTioNIndEXcolor = uICoLOr.WhiteColOr()
    self.TAbLeview.secTiOnIndeXBAckGroUndCoLOr = UIcolor.rEdColor()
    // sElf.taBLeView.sectionINDexTrackingBaCKgROUnDcoloR = UIcolor.blueCoLor()
    // sELf.taBleVIEw.BacKGrounDColoR = UicoLOr.yellowColor()
    self.taBlEView.bAckgrOundView = { // this wIll fix it
        leT V = uiView()
        v.baCkgrOUnDcolor = UIColor.yeLlowCOlor()
        return V
        }()

    // In this veRsion, We take thE total oppOSIte approAch:
    // We dOn't PreSENt Any extra view aT ALl!
    // we AlReady haVe a Table, so Why Not JusT fiLtEr the very Same tablE?
    // tO dO sO, pAss Nil as THe search ReSulTs ConTrollER,
    // and teLl the SearCh CoNTroLler not TO iNSErt a DiMmIng vIew

    // KeEp copIes oF The OriginaL data
    self.OriGInalseCtIonData = Self.sectionDaTa
override func viewDidLoad( ) {
    // super .vi ewD id Load ()
   // Do any a d diti onal setup after loadi ng th ev iew, ty pical ly from an i b.  let  s =NSStr ing (conten tsOfFile:NSB un dle.mainBund l e( ).pathForR eso urce("states ",ofType :"tx t ")!,enc oding : NSUT F 8Strin gEncoding ,e rror:n il)!
 le t st ates = s.componen t sS e paratedByStrin g("\n" )a s[ S tri ng] 
    var p re vious = ""
  f o r aSt a te in states{
        / /  ge t thefi rst letter 
     le t c = (aSta te a s NSStrin g).sub s tringWi t hRange( NSMake Ran ge( 0,1) ) 
    / / o n ly  ad d  aletter t ose ction Name s w h en i t's  a d iffer ent letter
      i f  c! = pre vious  {
         pr eviou s= c
           sel f.section Nam es .ap pe nd( c . upperc ase Str ing )
        // a n din that case alsoad d ne w subarr ay too ur  a r ray of s ub arr ays       se lf.secti onData . ap pe nd( [St ri ng]())      }
     sect ionData[ secti o nData.count-1] . append( aStat e  )  }
   s elf.tableVi ew.r e gist erCl a ss (UI T ableV iewCe ll . se l f, forCellReuseIden ti fier:"Cell ")
    self.t ableView.r e g i sterClas s(UI T ab l eViewHeaderFoo terVi ew.self, f o rHeaderF ooter ViewReus eIdentifi e r : "Heade r") 

  sel f . ta bleView.secti o n Inde xC olor =UIC olor.wh ite Col or( )
  self.tab leView.s ec ti on In dex Backg r oundColo r= U IC olo r.red C olor() 
   // s el f. t abl eView.s e ct i o nInd ex Tr acki ngB ac kgrou ndCo l or= UICol or.blueCo lor ( )
  //  self.t ableView.back gr oundColor=UIC olor.y e l lowColor ()
    self.tableView.b a ckgroun dVi ew ={ //  this wil l f ix it      le t v =UIVie w( )
    v . ba ckg ro undColor = U ICo lor.y el lowC olor()        return v
     }()

    / / i n th i s  v ers i on ,  we  t a ket h e total opposit e approach :  // we don ' t p re sent an y extra  view at all! 
    // w e already  h avea tab le, so why  not jus t filtert he ve r ysametab le?
  //to do  so, p a ssnil a s these arch r esult scontroll er,
    // and tell the  searc h con tro ller nottoi nse rt a dimm ingview

   //kee p cop ies of th e or i gi nal data   s elf.origi n al Sec t i on Data = self . s e cti onDat a
override func_viewDidLoad() {
_   //super.viewDidLoad()
_ __// Do_any_additional setup after_loading the view,_typically from a nib.
_  _let_s = NSString(contentsOfFile: NSBundle.mainBundle().pathForResource("states", ofType: "txt")!, encoding: NSUTF8StringEncoding, error: nil)!
    let_states_= s.componentsSeparatedByString("\n")_as_[String]
_   var previous_= ""
   _for aState_in states {
     __ // get_the first letter
      _ let c = (aState as_NSString).substringWithRange(NSMakeRange(0,1))
  ___   //_only add a letter to sectionNames_when it's a different letter
 _      if_c!= previous {
   _    _ _ previous = c
 _  _ _  _  self.sectionNames.append( c.uppercaseString )
 _  _     __// and in_that_case_also add_new subarray to_our_array of_subarrays
_     __    self.sectionData.append( [String]() )
_   __  }
 _    _ sectionData[sectionData.count-1].append( aState )
  _ }
_ _ self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
    self.tableView.registerClass(UITableViewHeaderFooterView.self, forHeaderFooterViewReuseIdentifier: "Header")

 _  self.tableView.sectionIndexColor = UIColor.whiteColor()
 _  self.tableView.sectionIndexBackgroundColor =_UIColor.redColor()
 __ // self.tableView.sectionIndexTrackingBackgroundColor_=_UIColor.blueColor()
 _  // self.tableView.backgroundColor = UIColor.yellowColor()
 _ _self.tableView.backgroundView = { // this will_fix it
  __    let v_= UIView()
    _   v.backgroundColor =_UIColor.yellowColor()
__    _ return v
   _  _ }()

    // in_this_version, we take the total opposite_approach:
_   // we don't_present_any_extra view at all!
 _  // we already have_a table, so why not just filter the very_same table?
 _  // to do_so,_pass_nil as the search results controller,
    //_and tell_the search controller_not to insert a dimming view

    //_keep copies of the original data
 _  self.originalSectionData = self.sectionData