I want to update a code object. Background: I made an app that had a UITB view. UITableViewCell has a name in the textLabel. The test label of this cell in detail is a date which can be changed / updated. Now I would like to change this date.
I wrote the following code:
var people = [NSManedAbject] () func saveDate (date: NSDate) {/ 1Delete Ad = //iPCification. Shared epiceration (). Representative managed contact as AppDelegate = App DeliGet. Contact the managed object! // 2 unit = NSEntityDescription.entityForName (Managed object contact in: "person", Managed Contact) person = People [dateIndexPath.row] // 3 person .setValue (Date: "Datam") // var var Error: NSError? If! ManagedContext.save (& Error) {println ("Can not save \" (error), \ (error? .userInfo) ")} // 5 people.append (person) tableView.reloadData ()}
Now, if I run this code: the date is updated successfully, but the date the cell has been updated has been shown 2 times. For example, if I have added 3 cells and have changed the date in the third cell, then I have now been shown 4 cells and two of them have the same content / duplicates.
Does anyone know how to solve this problem?
Each time you are adding an additional object to your array, your updated person < / Code> is already in the array and will display the new information when you reload your table data. To fix this, just take this line:
people.append (person)
No comments:
Post a Comment