Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1000465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:31:01+00:00 2026-05-16T07:31:01+00:00

how is possible to make an iphone tab that loads selected data from an

  • 0

how is possible to make an iphone tab that loads selected data from an array and changes based on user selection.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:31:01+00:00Added an answer on May 16, 2026 at 7:31 am

    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 NSUserDefaults from 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.

    // in the .h file
    #import <UIKit/UIKit.h>
    
    @interface MyViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
    
        // set up a mutable array which allows editing of the array
        NSMutableArray *myFavoritesData;
    
    }
    // set up a retained property
    @property (nonatomic, retain) NSMutableArray *myFavoritesData;
    
    @end
    
    
    // in the .m file
    // synthesize the getters/setters for your array
    @synthesize myFavoritesData;
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        // find cell that was just pressed
        UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    
        // get pointer for the label that we want to identify the cell by
        // the tag in this case is set to '5' in Interface Builder in the options for the label
        UILabel *someLabel;
        someLabel = (UILabel *)[cell viewWithTag:5];
    
        NSString *tmpFavorite = someLabel.text;
    
        // get the count of the current array and use that for the "new" row since the count
        // will always be 1 larger than the last object in the array (arrays start at 0, counts start at 1) 
        NSUInteger newRow = [self.myFavoritesData count];
        [self.myFavoritesData insertObject:tmpFavorite atIndex:newRow]; 
    
    }
    
    // save the mutable array into NSUserDefaults when the view is about to disappear
    - (void) viewWillDisappear:(BOOL)animated
    {
    
        NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
        [userDefaults setObject:self.myFavoritesData forKey:@"MyFavorites"]; 
    
        // synchronize the data now instead of waiting for the OS to synchronize it at some 
        // arbitrary time in the future
        [userDefaults synchronize];
    
    }
    

    Once you are in the new view controller, you can just read from the NSUserDefaults and populate the table from the array. For instance:

    // favorites view controller
    - (void)viewDidLoad {
    
        [super viewDidLoad];
    
        NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
        NSMutableArray *tmpArray = [[NSMutableArray alloc] init];
        tmpArray = [[userDefaults objectForKey:@"MyFavorites"] mutableCopy];
    
            if ([tmpArray count] == 0) {
    
                //
                // no favorites have ever been saved
                //
    
    
            } else {
    
                // load the favorites into some array you synthesized just like before
                self.tableFavoritesData = [[NSMutableArray alloc] init];
                self.tableFavoritesData = [[userDefaults objectForKey:@"MyFavorites"] mutableCopy];
    
                NSLog(@"favorites data is %d and %@", [self.tableFavoritesData count], self.tableFavoritesData);
    
    }
    
    [tmpArray release];
    }
    

    Then in your cellForRowAtIndexPath of 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.