0

そのため、アプリに検索バーを実装するのに問題があります。

メソッドはフィルタリングされたアイテムを見つけますが、何らかの理由でテーブルビューに表示されません。オブジェクトをfilteredListContentArrayに追加することと関係があると思います。

これを機能させるには、どのオブジェクトを追加する必要がありますか。

これが私のコードです:

{
[self.filteredListContent removeAllObjects]; // First clear the filtered array.
for (NSDictionary *dictionary in tableDataSource)   
{

    NSString *testString = [dictionary valueForKey:@"Title"];
    NSLog(@"String list to be Searched is %@", testString);
    //NSLog(@"Contents of list are %@", testString);
    NSComparisonResult result = [testString compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
    //NSObject *filteredObject = [dictionary objectForKey:@"Title"];
    if (result == NSOrderedSame)

    {
        NSLog(@":-)");
        NSLog(@"Resulted object is %@", [dictionary valueForKey:@"Title"]);
        [self.filteredListContent addObject:dictionary];
    }
    else
    {
        NSLog(@":-(");
    }
}


NSLog(@"Contents of Filtered list are %@", self.filteredListContent);}

その最後の NSLog は毎回 (null) を読み取りますが、その上の NSLog は常に正しいフィルター処理された項目を示します。

4

1 に答える 1

0

filteredListContent のメモリをどこに割り当てますか? そしてtableDataSource配列があります。filteredListContentまたはtableFataSource配列からテーブルを埋めますか? また、コンソールに出力することもできます [filteredListContent description];

于 2009-11-15T00:51:19.117 に答える