Good morning all, I followed this tutorial I am able to add a new contact and retrieve existing contacts , but what I am trying to accomplish is save the list that I add in a mutableArray and use that array to populate my TableView. I am getting this error
Contacts Introduction[5166:4971615] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object ( "!$_, value=>\"\n), emailAddresses=(\n \"!$_, value=>\"\n), postalAddresses=(\n)>" ) for key contactsKey'
Here
func insertNewObject(sender: NSNotification) {
print("How Many Times am I getting here ??")
if let contact = sender.userInfo?["contactToAdd"] as? CNContact {
objects.insert(contact, atIndex: 0)
let indexPath = NSIndexPath(forRow: 0, inSection: 0)
self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
}
print("How Many Objects ",objects.count)
let contactArray = objects as [CNContact]
let prefs = NSUserDefaults.standardUserDefaults()
prefs.setValue(contactArray, forKey: "contactsKey")
}
Any Help is appreciated.
Regards JZ