how is possible to make an iphone tab that loads selected data from an array and changes based on user selection.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Alx,
A simple scenario would be to create a NIB-based
UITableViewCell(there are plenty of tutorials out there for this) which has a label on it of some kind.What you can do is then grab the contents of the label when the user selects the cell and store that into a mutable array which then gets stored into the
NSUserDefaults.You can then access the
NSUserDefaultsfrom another view and use it to populate a “Favorites” tab like you’ve been asking about.A little bit of sample code to help (assuming the original data is in a UITableView like you said in a prior question). I’m writing this off the top of my head (un-tested code), so you’ll have to work out any bugs, but the idea is correct.
Once you are in the new view controller, you can just read from the
NSUserDefaultsand populate the table from the array. For instance:Then in your
cellForRowAtIndexPathof the favorites view controller you just access each string in each index of the array (so, string for index 0 would go into row 0, string for index 1 would go into row 1, etc) and this is what would populate your favorites table!Try that out.