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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:35:41+00:00 2026-05-15T09:35:41+00:00

I have a UITableView that was created from data coming from a mutable array.

  • 0

I have a UITableView that was created from data coming from a mutable array.

This is an array of dictionaries. So, in order to populate my table, I did something like

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

...

NSDictionary *umObject = (NSDictionary*)[listaDeObjectos objectAtIndex:indexPath.row];
NSString *oneName = [umObject objectForKey:@"name"];

[cell setText:oneName];

...

}

This is working fine, but now I am trying to implement a search on this table. I read a tutorial where the guy uses a search method like this…

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{
    [searchedData removeAllObjects];// remove all data that belongs to previous search
    if([searchText isEqualToString:@""] || searchText==nil){
        [myTableView reloadData];
        searching = NO;
        return;
    }

    searching = YES;
    NSInteger counter = 0;
    for(NSString *name in dataSource)
    {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
        NSRange r = [name rangeOfString:searchText];
        if(r.location != NSNotFound)
                [searchedData addObject:name];
        counter++;
        [pool release];
    }
    [myTableView reloadData];
}

as you can see, he has this line

for(NSString *name in dataSource)

where name is an entry from dataSource (??)

This sounds like the table being populated from some kind of array, but, as far as I know, my table was not populated from an array directly, but instead, from values I extracted on the first part of my code, one by one.

I am not sure if I understood the concept of datasource.

I have read the docs but I am still not understanding that.

What is this datasource? Does my table has one? If not, how do I search my table?

Cay you guys help?

thanks

  • 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-15T09:35:42+00:00Added an answer on May 15, 2026 at 9:35 am

    Your datasource is your class where you have all this UITableView related methods (tableView:cellForRowAtIndexPath: etc.). This class must adopt UITableViewDataSource protocol.

    When you provide data for each of your cell, you take it from your array listaDeObjectos.
    When you search, you want to provide only several items from your array, these items must adopt your search criteria.

    So when you are not in “search mode”, you must provide data from your array (listaDeObjectos).
    When you are in “search mode”, you should provide data from separate array which must contain only specific items that adopt your search criteria. UISearchBar calls searchBar:textDidChange: method where you have to check every item in your listaDeObjectos array, and if this item is good for search text provided by UISearchBar, add this item to that separate array. Then you call reloadData method which causes all table view methods to be invoked.
    So idea is to provide data from “search array” if you are search, and from listaDeObjectos if you are not search.

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

Sidebar

Related Questions

I have a UITableView showing data from a plist file. For this table view,
I have a table that displays data from a single array and organizes the
I have a UITableView that collects data from a database. What I would like
I have a UITableView that lists comments from various users. I save all of
I have a UITableView that is being populated by core data. Now, when I
I have a UITableView that displays various nsstrings from a custom object called a
I have a UITableView that displays some data that is read in at runtime
I have a ViewController that contains a UITableView in which the cells are created
I have a UITableView which loads its data from the web. It takes a
I have implemented a UITableView with the NSFetchedResultsController to load data from an sqllite

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.