views:

455

answers:

2

Basically, I have a UISearchBar searching an NSMutableArray of stories that make up an RSS feed, and when you select a story, it loads in my app's UIWebView. It's difficult to explain, but I have a list of entries 1, 2, 3, and 4 and you search for '4'. 4 will be the first entry in the now-filtered list of data, right? You'd think that by selecting 4, it would load in the UIWebView. Well, the app seems to not recognize that you're selecting the first entry in a filtered list of data, and instead thinks that you're selecting the first entry in the unfiltered array of data, so it loads entry 1. Everything looks right in my code, but obviously it isn't.

I know it's a confusing problem, but I hope I made it somewhat clear. Anyway, here's the relevant source so that you may see exactly what I mean:

Search.h: http://www.scribd.com/doc/13107802/Searchh

Search.m: http://www.scribd.com/doc/13107812/Searchm

A: 

this article provides a good tutorial of how to search on an nsmutablearray!

Using the UISearchBar to filter a TableView on Keypress

Andy Jacobs
Link doesn't work, could you summarize main points here?
JOM
A: 

To really answer this question, some further details would be required. For example, does an NSLog of the filtered list inside the searchBar: textDidChange: function return the expected data?

If it does, I would assume that the problem lies not in your search function, but in the cellForRowAtIndexPath: method of your TableView's DataSource. It seems like you've correctly implemented the numberOfRowsForTableView method, as the correct number of results are returned, but cellForRowAtIndexPath: has to distinguish what list of data to pull from.

Endemic