//
//  ContactsViewController.swift
//  V
//
//  Created by Dulio Denis on 7/5/16.
//  Copyright © 2016 Dulio Denis. All rights reserved.
//

import UIKit
import CoreData
import Contacts
import ContactsUI

class ContactsViewController: UIViewController, ContextViewController {

    // in order to fulfill the ContextVC Protocol
    var context: NSManagedObjectContext?
    
    private let tableView = UITableView(frame: CGRectZero, style: .Plain)
    private let cellIdentifier = "ContactCell"
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        navigationController?.navigationBar.topItem?.title = "All Contacts"
        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "add"), style: .Plain, target: self, action: "newContact")
        
        // Account for the Navigation Bar
        automaticallyAdjustsScrollViewInsets = false
        tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
        tableView.tableFooterView = UIView(frame: CGRectZero)
        
        fillViewWith(tableView)
    }
    
    
    func newContact() {
        print("New Contact")
    }

}

//
//  ContactsViewController.swift
//  V
//
//  Created by Dulio Denis on 7/5/16.
//  Copyright © 2016 Dulio Denis. All rights reserved.
//

import UIKit
import CoreData
import Contacts
import ContactsUI

class ContactsViewController: UIViewController, ContextViewController {

    // in order to fulfill the ContextVC Protocol
    var context: NSManagedObjectContext?
    
    private let tableView = UITableView(frame: CGRectZero, style: .Plain)
    private let cellIdentifier = "ContactCell"
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

        title = "All Contacts"
        navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "add"), style: .Plain, target: self, action: "newContact")
        
        // Account for the Navigation Bar
        automaticallyAdjustsScrollViewInsets = false
        tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: cellIdentifier)
        tableView.tableFooterView = UIView(frame: CGRectZero)
        
        fillViewWith(tableView)
    }
    
    
    func newContact() {
        print("New Contact")
    }

}

--- 
+++ 
@@ -24,7 +24,7 @@
     override func viewDidLoad() {
         super.viewDidLoad()
 
-        title = "All Contacts"
+        navigationController?.navigationBar.topItem?.title = "All Contacts"
         navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage(named: "add"), style: .Plain, target: self, action: "newContact")
         
         // Account for the Navigation Bar
Set the title to the ContactsVC
