iPhone SDK: How to restore NSMutableArray dataset after applying a filter?
<p>I am trying to write a simple filter mechanism such that when the user types in a filter string the  UIPicker filters it's data. I have it working almost.</p>

<p>This is my filter code and it works. My question is, once I have applied a filter to a datasource,  how  can I remove the predicate and restore the original dataset? I  am using NSMutableArray for my datasource.</p>

<pre><code>NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] 'B'"];
[arrayCountryChoices filterUsingPredicate: predicate];
[pickerCountry reloadComponent:0];
</code></pre>

<p>Thank you in advance.</p>

<p><strong>Edit</strong></p>

<p>With this suggested approach I am getting this error. <strong>* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*</strong> -[UIView numberOfComponentsInPickerView:]:</p>

<p>I am not sure why. This is all the related code  I can think of. I also checked my connections in IB. Any idea why?</p>

<pre><code>//create data
    arrayCountryChoices = [NSArray arrayWithObjects:@"foo",@"bar",@"baz",nil];  

    //copy the original array to searchable array
    arraySearchResults = [arrayCountryChoices mutableCopy];

- (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>}</p>
