title: iPhone SDK: NSInvalidArgumentException -UIView numberOfComponentsInPickerView
body: <p>I am trying to develop a simple search mechanism on a UIPicker. The approach I am using is to keep two arrays. My problem is that for some reason I am getting this run-time error.</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UIView numberOfComponentsInPickerView:]
  </code></pre>
  
  <p>Here are the array declarations.</p>
  
  <pre><code>//data source for UIPicker NSArray
  *arrayCountryChoices;
  
  //search results buffer 
  NSMutableArray *arraySearchResults; 
  
  //properties
  @property(nonatomic,retain) NSArray*arrayCountryChoices; 
  @property(nonatomic,retain) NSMutableArray *arraySearchResults;
  </code></pre>
  
  <p>Here is where I initialize the data</p>
  
  <pre><code>//create data
    arrayCountryChoices = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil];
  
  //copy the original array to searchable array
  arraySearchResults = [arrayCountryChoices mutableCopy];
  </code></pre>
  
  <p>An the picker methods.</p>
  
  <pre><code>- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
  return 1;
  }
  - (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
  return [arraySearchResults count];
  }
  - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
  return [arraySearchResults objectAtIndex:row];
  }
  - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
  //grab the selected country
  strUserChoice = [arraySearchResults objectAtIndex:row];
  }
  </code></pre>
  
  <p>Here is  the search code for completeness although not really relevant yet as the app dies before we ever get here.</p>
  
  <pre><code>//filter on search term
  NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", strSearchText];
  [arraySearchResults filterUsingPredicate: predicate];
  [pickerCountry reloadComponent:0];
  </code></pre>
  
  <p>I have also dragged datasource  and delegate connections from the UIPicker to  Files Owner in Interface Builder.
  Any ideas?
  Thanks in advance.</p>