I want my app to work just like the ‘contacts’ app on iOS. When a user selects a certain TableViewCell, i want to load certain data.

No Matter which cell is pressed, Either “Joseph, Richard, or Shannon”, This view comes up:


Both of the views look the exact same, but they just display different information. So i guess my question is: How can I programmatically set a key @”cell1″ @”cell2″, etc… for each cell using NSUserDefaults? But here is the catch, I dont know how many cells will be added, so i cant hard code this, How can I create a key for each table view cell for how ever many is added? Thanks for the help!
Perhaps you don’t want to use
NSUserDefaults…. that’s only used for persistant user information, such as preferences. It’d be better to use Core Data for that sort of thing.One idea, since you want to tag the views, is to use the
-[UIView setTag:]orUIView.tagproperty/method on theUITableViewCellduring cell dequeueing. Using theUITableViewdelegate methods, you could detect a tap on the cell, retrieve its tag, and look up theNSUserDefaults, or better, your database.The preferred way, is to keep an indexed database, dequeue a cell, and when it’s tapped, navigate to the detail pane using the cell’s index. This is a far more representative programming model, than tagging a view and using
NSUserDefaultsto pull the data.