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 8832051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:26:42+00:00 2026-06-14T08:26:42+00:00

Apologies in advance if my question is unclear as I’m new to iOS programming

  • 0

Apologies in advance if my question is unclear as I’m new to iOS programming (and programming in general).

Right now, I have a UITableView that displays an alphabetical NSMutableArray of the names of a user’s friends, something like:

friends: { @"Andy",@"Anand",@"Bob",@"Cat" };

I have another NSMutableArray that holds the matching ages of the user’s friends, something that the user never sees but is passed on to the previous view controller after the user picks the name of a friend. This ages array is something like:

friendsAges: {@"25",@"23",@"30",@"22"};

My question is, if I added a searchBar to the UITableview of the friends’ names, how do I make sure that the corresponding age object is sent back to the previous view controller if the user picks a name from the filtered array, searchResultsTableView?

For example, if there wasn’t a searchBar, picking “Bob” would also send “30” to the previous controller. But if the user types in “bo” and only Bob is shown in the filtered searchResultsTableView, then age “25” will be sent instead to the previous controller b/c it’s the first index.

Here’s my incorrect code:

if (tableView == self.searchDisplayController.searchResultsTableView) {

    NSString *theFriend = [_filteredFriendArray objectAtIndex:indexPath.row];

    // not sure what I should use instead for the _filteredFriendArray below
    NSString *theFriendAge = [_filteredFriendArray objectAtIndex:indexPath.row];

    [self.delegate friendPickerViewController:self
                              didSelectFriend:theFriend
                    didSelectFriendAge:theFriendAge];

} else { //if not using search bar and seeing filtered search results
    NSString *theFriend = [friends objectAtIndex:indexPath.row];
    NSString *theFriendAge = [friendsAge objectAtIndex:indexPath.row];

    [self.delegate friendPickerViewController:self
                              didSelectFriend:theFriend
                    didSelectFriendAge:theFriendAge];
}

I feel like it might be easier to use an NSDictionary instead of trying to match the index of a filtered search view back to main array, but am not sure how to best do that.

Any help would be appreciated!

  • 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-06-14T08:26:43+00:00Added an answer on June 14, 2026 at 8:26 am

    You are right, it is easier to use NSDictionary. Each person can be represented by an NSDictionary like @{@”name”:@”Stephen Hawking”, @”age”:70}. Populate your friends table view with [personDict objectForKey:@”name”] and on selection get the value for [person objectForKey:@”age”] and pass it back to the previous view controller.

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

Sidebar

Related Questions

Apologies in advance for the length of this question! I have a data structure
Apologies in advance for the super-newbie question. I'm learning to use pandas, and have
Apologies in advance for a policy, rather than a programming question, but given the
Apologies for the seeming triviality of the question in advance. Seeing as that the
Apologies in advance if this question is badly worded! I have a MySQL table
I am new to programming, so please accept my apologies if this question is
Apologies in advance for the long-winded question. I'm really a database programmer, but have
I'm new to Python so apologies in advance if this is a stupid question.
Gentlepeeps, I'm new with Jquery. Apologies in advance for the basic question. I'm trying
Apologies in advance if this becomes a very long question... Background Info I have

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.