I want to populate a tableview with contact details that I have entered in the app.
first i have a table view controller that will show the list of entered contacts. its swift file looks like this.
import Contacts
import ContactsUI
class thecontacts: UITableViewController, CNContactPickerDelegate, UIPickerViewDelegate {
let contacts = CNMutableContact()
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell!
return cell
}
I want to populate this from another view controller. I want to populate this tableview with a persons name, and have it as a contact in the tableview. This view controllers swift file is:
import Contacts
class newContact: UIViewController {
//outlets
@IBOutlet weak var nameTextField: UITextField!
@IBOutlet weak var emailTextField: UITextField!
var tableViewController: newContact? = nil
override func viewDidLoad() {
}
@IBAction func addBuddy(sender: AnyObject) {
let contacts = CNMutableContact()
contacts.nickname = nameTextField!.text!;
contacts.emailAddresses = [CNLabeledValue(label: nil, value: emailTextField.text!)]
self.tableViewController?.addBuddy(contacts)
dismiss()
}
func dismiss(){
dismissViewControllerAnimated(true, completion: nil)
}
}
my tableViewController file is called thecontacts.swift. My new contact details viewController is called newContacts.swift.
the problem I have is that the details I enter into the newContact file are not appearing in my thecontacts table view.