How to integrate a SearchBar from an Array of Dictionaries

Discussion in 'iOS Programming' started by Nekbeth, Mar 28, 2011.

  1. Nekbeth macrumors member

    Nekbeth

    Joined:
    Feb 20, 2011
    Location:
    Vatican City
    #1
    Hi, I'm trying to add a SearchBar to an Array of Dictionaries. I'm following a tutorial from the book "Beginning iPhone SDK" , in which case uses a .plist of a Dictionary of Arrays. I tried to use the same logic from that example. You can see the .plist photos of both cases after the code. Any kind of advice will be much appreciated, let me know if you need more code about the variables. Thank you

    Here is the way the book copies all the movies in the dictionary into the list of Movies array:
    Code:
    listOfMovies = [[NSMutableArray alloc] init]; 
    for (NSString *year in array)     //---get all the years---      
    
    {
       //---get all the movies for a particular year---
       NSArray *movies = [movieTitles objectForKey:year]; 
       for (NSString *title in movies)
    
      {
    
        [listOfMovies addObject:title];
    
      }
    
    }
    
    I'm trying to copy all my recipes of the array to a List of Recipes array: (here is what I got so far, I'm not sure i'm copying the right way)

    Code:
     
    listOfRecipes = [[NSMutableArray alloc] init]; 
     for (NSString *????)                                 //Here is where I get lost, RecipesData represents my Data Source
    
        {
    
            {
     

    Attached Files:

  2. Nekbeth, Mar 28, 2011
    Last edited: Mar 28, 2011

    Nekbeth thread starter macrumors member

    Nekbeth

    Joined:
    Feb 20, 2011
    Location:
    Vatican City
    #2
    Ok, I 've try some write some code by my own in order to add the Titles of my recipes to the NSMutable Array "ListOfRecipes. Xcode doesn't show me any errors or warnings , Is this OK ?

    Code:
    //---copy all the recipes titles in the Array INTO the listOfRecipes Array--- 
        listOfRecipes = [[NSMutableArray alloc]init];
        
        //Obtaining the Data Source from the Main Array
        NSDictionary *array = [ self.RecipesData  valueForKey:@"Rows"];
        
        //Get the Titles of the Dictionaries.
        NSArray *Children = [array objectForKey:@"Title"];
        
        Children = listOfRecipes;
     

Share This Page