UISearchDisplay - 应用程序崩溃
我有一个大问题。我从 Apple 资源页面的表搜索示例中复制了一些代码。
情况如下:
#pragma mark -
#pragma mark Content Filtering
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[self.chatMessagesArrayCopyForSearching removeAllObjects]; // First clear the filtered array.
if ([searchText length]==0)
{
}else
{
for (FriendMessage *friend in chatMessagesArray)
{
NSComparisonResult result = [friend.message compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
if (result == NSOrderedSame)
{
[self.chatMessagesArrayCopyForSearching addObject:friend];
NSLog(@"%@", friend.message);
}
}
}
}
例如,当我输入一个字母,然后输入第二个字母时,应用程序崩溃。可能有 friend.message 的东西,因为控制台说:
-[AccessibilityObjectWrapper message]: unrecognized selector sent to instance 0x5d8d580
FriendMessage 是自定义类,继承自 NSObject,而 message 是标准 NSString *。
感谢您提供的任何
mapedd
帮助 抱歉,如果代码可读性不太好
i've got huge problem. I've copied some code from table search sample from Apple Resource pages.
here's the case:
#pragma mark -
#pragma mark Content Filtering
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope
{
[self.chatMessagesArrayCopyForSearching removeAllObjects]; // First clear the filtered array.
if ([searchText length]==0)
{
}else
{
for (FriendMessage *friend in chatMessagesArray)
{
NSComparisonResult result = [friend.message compare:searchText options:(NSCaseInsensitiveSearch|NSDiacriticInsensitiveSearch) range:NSMakeRange(0, [searchText length])];
if (result == NSOrderedSame)
{
[self.chatMessagesArrayCopyForSearching addObject:friend];
NSLog(@"%@", friend.message);
}
}
}
}
application crash when for example i type one letter, and then the second letter. probably there something with friend.message becouse console says:
-[AccessibilityObjectWrapper message]: unrecognized selector sent to instance 0x5d8d580
FriendMessage is custom class, inherited from NSObject, and message is standard NSString *.
thanks for any provided help
mapedd
p.s. sorry if code isn't very readable
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,它在您的错误中显示“AccessibilityObjectWrapper”,这告诉您在某个时候可能存在一个 FriendMessage 对象,但现在它已经消失了:)
这通常是因为您的代码中某处缺少保留。
您在哪里创建 FriendMessage 对象数组 - 您可以编辑您的问题并添加该代码吗?
谢谢。
The fact that it says 'AccessibilityObjectWrapper' in your error tells you that there might have been a FriendMessage object there at some point but it's gone now :)
This is typically because there is a missing retain somewhere in your code.
Where do you create the array of FriendMessage objects - can you edit your question and add that code as well?
Thanks.