Question: Making CNContact on tableView presistant using NSUserDefaults

Question

Making CNContact on tableView presistant using NSUserDefaults

Answers 0
Added at 2016-12-31 18:12
Tags
Question

I am trying to save the CNContact as an NSUserDefault object when the save button it pressed. Then When the App opens up I want the CNContacts to be presented in the tableview. I cannot see where I am going wrong with it.

var objects = [CNContact]()

let myDefaults = NSUserDefaults.standardUserDefaults()
let myContacts = "myContact"


override func viewDidLoad() {
    super.viewDidLoad()
    getSavedContact()
    }


func getSavedContact(){

    myDefaults.stringForKey(myContacts)


    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
        let contact = self.objects[indexPath.row]
        return cell
    }
}


@IBAction func SaveContact (sender: AnyObject) {
    myDefaults.stringForKey(myContacts) 
}
Answers
Source Show
◀ Wstecz