Help with some Logic in "Search Bar"

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

  1. macrumors member

    Nekbeth

    Joined:
    Feb 20, 2011
    Location:
    Vatican City
    #1
    Hi, I'm implementing a Search bar, everything is ready except I need to copy all of my Dictionary Titles to an array called listOfRecipes. I already have to path to access them, which is the following:
    Code:
     NSUInteger section = [indexPath section];
    
        NSUInteger row = [indexPath row];
    
    
    
    
    
        NSString *key = [keys objectAtIndex:section];
    
        NSArray *nameSection = [names objectForKey:key];
    
        Something = [[nameSection objectAtIndex:row]valueForKey:@"Title"];    
    If I try to type that in ViewDidLoad, it tells me : Use of undeclared identifier "indexPath" both for section and for row. I know it's because they only work inside index methods. But how can I adapt it for ViewDidLoad ? Some tutorials use a different copy method for that.. this is an example of one of them:

    Code:
    //---copy all the movie titles in the dictionary into the listOfMovies array---
    
    
         listOfRecipes = [[NSMutableArray alloc] init];
    
         
    
         for (NSString *year in array)     //---get all the years---            
    
         {
    
              //---get all the recipes for a particular category---
    
                    NSArray *movies = [movieTitles objectForKey:year];
    
                    for (NSString *title in movies)
              {
    
                   [listOfRecipes addObject:title];
    
              }
    
         }
    
    Here a photo of the plist, Thank you :)
     

    Attached Files:

    • 1.jpg
      1.jpg
      File size:
      31.8 KB
      Views:
      80
  2. macrumors regular

    Joined:
    Oct 18, 2007
    Location:
    Chicago-area
    #2
    You can't.

    Where do you expect indexPath to be set? When do you expect indexPath to be set? Perhaps you should check the View Programming Guide to see the View Lifecycle and understand what viewDidLoad means.
     
  3. thread starter macrumors member

    Nekbeth

    Joined:
    Feb 20, 2011
    Location:
    Vatican City
    #3
    I know you can't , but there are way to call it differently from using index, and that's what my question is about. ViewDidload method is everything you want to start after the view loaded. So, do you know another way to get those titles and not use index to find the rows? I'm very close to get them using other methods, such as "all keys" , "valueForKey", "Addobject", etc.
     

Share This Page