单击键盘上的任何值时出错
大家好,
当我单击键盘上的任何值时,我不断收到此错误...我可以运行我的代码,但当我想做搜索时收到此错误...
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM rangeOfString:options:]: unrecognized selector sent to instance 0x4e2a830'
*** Call stack at first throw:
请在这里帮助这个菜鸟..我已经智穷了... =(
- (void) searchTableView {
NSString *searchText = searchBar.text;
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
for (NSDictionary *patients in listOfItems)
{
NSArray *array = [patients objectForKey:@"Patients"];
[searchArray addObjectsFromArray:array];
}
for (NSString *sTemp in searchArray)
{
NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (titleResultsRange.length != 0)
[copyListOfItems addObject:sTemp];
}
[searchArray release];
searchArray = nil;
}
Hi any kind souls out there,
I keep getting this error when i am click any value on the keyboard... I can run my codes but get this error when i want to do a search...
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM rangeOfString:options:]: unrecognized selector sent to instance 0x4e2a830'
*** Call stack at first throw:
Please help this noob here.. I am at end wits... =(
- (void) searchTableView {
NSString *searchText = searchBar.text;
NSMutableArray *searchArray = [[NSMutableArray alloc] init];
for (NSDictionary *patients in listOfItems)
{
NSArray *array = [patients objectForKey:@"Patients"];
[searchArray addObjectsFromArray:array];
}
for (NSString *sTemp in searchArray)
{
NSRange titleResultsRange = [sTemp rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (titleResultsRange.length != 0)
[copyListOfItems addObject:sTemp];
}
[searchArray release];
searchArray = nil;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
搜索数组中的对象是 NSArray 对象,这意味着它们不会响应选择器 rangeOfString:,因为这是一个 NSString 方法
应该是这样的:
The objects in your search array are NSArray objects, this means that they do not respond to the selector rangeOfString: as that is a NSString method
should be something like:
您正在 searchArray 中添加数组对象。
你的应用程序在这里崩溃
NSString *sTemp in searchArray
因为 sTemp 包含 NSArray 对象而不是 NSString 对象。You are adding array object in your searchArray.
your app is getting crash
NSString *sTemp in searchArray
here because sTemp contains NSArray object not NSString object.