gpt4 book ai didi

ios - 我的代码如何产生此崩溃 : [NSConcreteData count]: unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-11-29 02:55:33 25 4
gpt4 key购买 nike

我在 BugSense 中看到了这个崩溃:

-[NSConcreteData count]: unrecognized selector sent to instance 0x14e57f10 - NSInvalidArgumentException

在这段代码中:

+ (NSMutableArray *)applyFilters:(NSMutableArray *)theItems fromFilter:(NSDictionary *)filters
{
NSMutableArray *items = [[NSMutableArray alloc] initWithArray:theItems];

if ([[filters allKeys] count] > 0)
{
NSMutableArray *tempFilteredItems = [[NSMutableArray alloc] init];

for (NSString *key in [filters allKeys])
{
NSMutableString *convertedKey = [NSMutableString stringWithString:key];

[convertedKey replaceOccurrencesOfString:@" "
withString:@"_"
options:NSCaseInsensitiveSearch
range:NSMakeRange(0, [convertedKey length])];

NSArray *tempFilterAttributes = [NSArray arrayWithArray:filters[key]];

for (NSDictionary *item in items)
{
if (![[item[convertedKey] componentsSeparatedByString:@"*"] firstObjectCommonWithArray:tempFilterAttributes])
{
if (![tempFilteredItems containsObject:item])
{
[tempFilteredItems addObject:item];
}
}
}

[items removeObjectsInArray:tempFilteredItems];
[tempFilteredItems removeAllObjects];
}
}

return items;
}

为什么/这是怎么发生的?

堆栈跟踪是:

    CoreFoundation  <redacted> + 130    
1 libobjc.A.dylib objc_exception_throw + 38
2 CoreFoundation <redacted> + 202
3 CoreFoundation <redacted> + 706
4 CoreFoundation _CF_forwarding_prep_0 + 24
5 CoreFoundation <redacted> + 28
6 Video Games +[Helper applyFilters:fromFilter:] (Helper.m:2862)
7 Video Games -[WishlistViewController loadUp] (WishlistViewController.m:409) + 29303
8 Video Games -[WishlistViewController viewWillAppear:] (WishlistViewController.m:363) + 27955
9 UIKit <redacted> + 374
10 UIKit <redacted> + 612
11 UIKit <redacted> + 572
12 UIKit <redacted> + 44
13 UIKit <redacted> + 184
14 UIKit <redacted> + 380
15 QuartzCore <redacted> + 142
16 QuartzCore <redacted> + 350
17 QuartzCore <redacted> + 16
18 QuartzCore <redacted> + 228
19 QuartzCore <redacted> + 314
20 UIKit <redacted> + 126
21 CoreFoundation <redacted> + 20
22 CoreFoundation <redacted> + 286
23 CoreFoundation <redacted> + 738
24 CoreFoundation CFRunLoopRunSpecific + 524
25 CoreFoundation CFRunLoopRunInMode + 106
26 GraphicsServices GSEventRunModal + 138
27 UIKit UIApplicationMain + 1136
28 Video Games main (main.m:16) + 888911
29 libdyld.dylib <redacted> + 2

最佳答案

问题与您提供的代码无关。错误消息表明消息 count 被发送到 class NSConcreteData,这与 NSData 基本相同, 这样的类方法是不存在的。
我建议您设置一个异常断点(在 Xcode 中选择左侧的断点导航器,单击左下角的+,然后选择添加异常断点)。
当您执行该应用程序时,它将在错误指令处停止。

编辑(由于您现在提供的堆栈跟踪):
堆栈跟踪确实表明您的方法 applyFilters:fromFilter: 是导致崩溃的原因。在此方法中发送消息 count 的唯一位置是语句 [[filters allKeys] count]。看起来 count 被发送到一个 NSConcreteData 对象,而不是像您预期的那样发送到一个 NSArray 对象。一个原因可能是参数 filters,它应该是一个 NSDictionary,是一个不同类型的对象。
所以当应用程序停止在异常断点时,请检查实例的类 filters

关于ios - 我的代码如何产生此崩溃 : [NSConcreteData count]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23940292/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com