[_UITableViewSeparatorView rangeOfString:]:无法识别的选择器发送到实例
我在表中搜索时执行以下代码时遇到问题。这段代码在其他地方工作得很好。但目前它给出的错误为
[_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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看来您过度释放了存储在 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.
这意味着字符串应驻留在内存中的内存已被释放,并且该位置上有另一个对象(在您的情况下为 _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
您在
dataSource
中放入了什么?显然,它包含一个不是 NSString 的对象。What are you putting in
dataSource
? Evidently, it contains an object that is not an NSString.