[_UITableViewSeparatorView rangeOfString:]:无法识别的选择器发送到实例

发布于 2024-10-17 02:12:05 字数 1108 浏览 5 评论 0原文

我在表中搜索时执行以下代码时遇到问题。这段代码在其他地方工作得很好。但目前它给出的错误为

[_UITableViewSeparatorView rangeOfString:]:无法识别的选择器发送到实例 0x6041790

以下是困扰我的代码。请让我知道其中存在的错误。

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  {
       [tableData removeAllObjects];// remove all data that belongs to previous search
       if([searchText isEqualToString:@""] || searchText==nil)
       {
            [displayTable reloadData];
            return;
       }
    NSInteger counter = 0;
       for(NSString *name in dataSource)
    {
            NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
            NSRange r = [name rangeOfString:searchText];
            if(r.location != NSNotFound)
            {
                if(r.location== 0)//that is we are checking only the start of the names.
                {
                    [tableData addObject:name];
                }
            }
            counter++;
            [pool release];
        }

    [displayTable reloadData];    }

提前致谢!!

期待您的回复。

谢谢

I am having a problem in executing the following code while searching in the table. This code works fine elsewhere. But currently it is giving an error as

[_UITableViewSeparatorView rangeOfString:]: unrecognized selector sent to instance 0x6041790

Following is the code that is troubling me. Please let me know the bug gidden in there.

- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
  {
       [tableData removeAllObjects];// remove all data that belongs to previous search
       if([searchText isEqualToString:@""] || searchText==nil)
       {
            [displayTable reloadData];
            return;
       }
    NSInteger counter = 0;
       for(NSString *name in dataSource)
    {
            NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
            NSRange r = [name rangeOfString:searchText];
            if(r.location != NSNotFound)
            {
                if(r.location== 0)//that is we are checking only the start of the names.
                {
                    [tableData addObject:name];
                }
            }
            counter++;
            [pool release];
        }

    [displayTable reloadData];    }

Thanks in advance!!

Looking forward to your responses.

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情话已封尘 2024-10-24 02:12:06

看来您过度释放了存储在 dataSource 中的字符串。我会检查您使用/创建这些字符串的任何地方,以确保您释放它们的次数不会超过应有的次数。

It looks like you're over-releasing the strings that you have stored in dataSource. I would check any place that you use/create those strings to make sure that you aren't releasing them more times than you should.

虫児飞 2024-10-24 02:12:06

这意味着字符串应驻留在内存中的内存已被释放,并且该位置上有另一个对象(在您的情况下为 _UITableViewSeparatorView )。确保您没有过度释放数组中的字符串

您可以尝试在仪器中使用 NSZombiesEnabled 进行搜索: 链接

It means that the memory where the string should reside in memory was freed and there is another object on that place (_UITableViewSeparatorView in your case). Make sure that you are not over-releasing the string in array

You can try to search with NSZombiesEnabled in instruments: link

忆伤 2024-10-24 02:12:06

您在 dataSource 中放入了什么?显然,它包含一个不是 NSString 的对象。

What are you putting in dataSource? Evidently, it contains an object that is not an NSString.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文