Iphone 重复条目的Xcode tableview搜索筛选器

Iphone 重复条目的Xcode tableview搜索筛选器,iphone,uitableview,search,xcode4,Iphone,Uitableview,Search,Xcode4,我有一个表格视图,在不同的部分标题下有一些相同的单词,还有一个搜索字段。 当你搜索时,你会得到重复的结果,我想从我的搜索结果中过滤这些重复的单词 有没有办法做到这一点?这里是我用来做这件事的一段代码。您需要比较每个对象中的唯一字符串以识别重复项。在本例中,我使用“myObject.uniqueID”来实现。创建一个没有重复项的数组,然后[tableView reloadData] - (void) removeDuplicates{ NSMutableDictionary * d = [[[N

我有一个表格视图,在不同的部分标题下有一些相同的单词,还有一个搜索字段。 当你搜索时,你会得到重复的结果,我想从我的搜索结果中过滤这些重复的单词


有没有办法做到这一点?

这里是我用来做这件事的一段代码。您需要比较每个对象中的唯一字符串以识别重复项。在本例中,我使用“myObject.uniqueID”来实现。创建一个没有重复项的数组,然后
[tableView reloadData]

- (void) removeDuplicates{

NSMutableDictionary * d = [[[NSMutableDictionary alloc] initWithCapacity:0] autorelease];
NSMutableArray * noDuplicatesArray = [[[NSMutableArray alloc] initWithCapacity:0] autorelease];

Object* myObject; // whatever your object is
NSString * key;
NSString * value;

for ( int i=0; i<[duplicatesArray count]; i++ ){

    myObject = [duplicatesArray  objectAtIndex:i];
    key = myObject.uniqueID; // whatever makes this object unique (like a stock number, or ID)
    value = [d objectForKey:key];

    if ( value == nil ){

        [d setObject:key forKey:key];
        [noDuplicatesArray addObject:deal];
    }
}
    // now your noDuplicatesArray will have only unique entries. 
    // reload your tableview using the noDuplicatesArray


}
-(void)删除的副本{
NSMutableDictionary*d=[[NSMutableDictionary alloc]initWithCapacity:0]自动释放];
NSMutableArray*NodeUpplicateSarray=[[NSMutableArray alloc]initWithCapacity:0]自动释放];
Object*myObject;//无论对象是什么
NSString*键;
NSString*值;

对于(int i=0;i)您正在决定搜索期间显示的内容。如果不需要,为什么要添加重复项。我不理解这个问题。