Need help with NSUserDefaults and UITableView

Discussion in 'iOS Programming' started by guydor, Mar 22, 2010.

  1. guydor macrumors member

    Mar 10, 2009

    I have an UITableView with an edit button that allows the user to change the rows order.
    I would like to save this order even the user quits the application.
    Unfortunately I have no experience with NSUserDefaults.
    Would you like to instruct me how to save the UITableView rows order please?

  2. KoolStar macrumors demi-god


    Oct 16, 2006
    You have to save the order of the datasource for the uitableview in the nsuserdefaults. Depending on if you are using custom objects to load data into the tableview your objects me need to conform to nsencoding and decode to be able to store the data in the user defaults. One such method for saving the data would be at the end of the tableview editing method that you write the data to the userdefaults. Then on viewDidLoad you reload the data for next time.

Share This Page