Hi I have a tableview and this is my code in MyItemTableViewController Class
var itemList = [String]()
@IBAction func saveItemToList (segue: UIStoryboardSegue) {
let AddNewItemViewController = segue.sourceViewController as! addItemTableViewController
let name = AddNewItemViewController.itemName
if name == "" {
}
else {
itemList.append(name!)
let indexToInsert = itemList.count == 0 ? 0 : itemList.count - 1
let indexPath = NSIndexPath(forRow: indexToInsert, inSection: 0)
tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: UITableViewRowAnimation.Automatic)
}
}
How can I save my array using NSUserDefaults I was trying some ways but it didn't work for me.