- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个非常烦人的错误。可能有一个简单的解决方案,但我无法得到它。
我使用 NSPredicate
通常没有任何问题。现在出现以下错误:Terminating app due to uncaught exception ' NSUnknownKeyException
',原因:'[<TestClass 0x10cf3b80> valueForUndefinedKey:]: this class is not key value coding-compliant for the key testValue.
'
NSString* predicateString = [NSString stringWithFormat:@"name CONTAINS[cd] %@",@"testValue"];
NSPredicate* filterPredicate = [NSPredicate predicateWithFormat:predicateString];
NSArray* filtered = [all filteredArrayUsingPredicate:filterPredicate];
名字是一个NSString*
我类(class)的属性(property),都是一个数组,里面有我的对象。只是一些微不足道的代码,没有什么额外的。
感谢您的帮助!
最佳答案
如果您将谓词构建为 NSString,它应该是(注意额外的引号):
NSString* predicateString = [NSString stringWithFormat:@"name CONTAINS[cd] '%@'", @"testValue"];
或者,您可以更直接地构建它:
NSPredicate* filterPredicate = [NSPredicate predicateWithFormat:@"name CONTAINS[cd] %@", @"testValue"];
第二种方法使用 %@ 说明符自动将引号括起来。
关于ios - 通过 NSPredicate 过滤数组时出现 NSUnknownKeyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24183074/
这个问题已经有答案了: Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value codin
我尝试为 ios 做一个非常简单的应用程序。在 View 之间切换。当它在日志中启动此错误时: Terminating app due to uncaught exception 'NSUnknown
一两天前开始学习 Swift。我遇到这个错误的次数比我想的要多——本质上,我意识到它与 IBOutlets 有关。删除 Storyboard 中的所有 socket 和按钮/对象,然后手动重新添加它们
这个问题已经有答案了: Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value codin
我对 Objective C 和 iOS 编程很陌生,并且遇到了这个非常奇怪的错误。相关应用程序使用我使用 NSObject 制作的自定义类型的一组预设值来初始化 NSMutableArray。这是由
This question already has answers here: Xcode - How to fix 'NSUnknownKeyException', reason: … this c
我在这里查看了这个问题的答案,但它们似乎都没有解决我遇到的问题,而且大多数其他答案都不是快速的,但我尝试了我理解的答案。 所有类名称都匹配, socket 具有正确的名称,并且没有未定义的 socke
这个问题在这里已经有了答案: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value c
这个问题在这里已经有了答案: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value c
app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this c
我在框架中有一个带有相应 xib 的自定义 View 。在界面生成器中,我将文件所有者和 View 本身设置为我的 UIView (TotalTokenCountView) 子类。我还在自定义 Vie
这个问题在这里已经有了答案: this class is not key value coding-compliant for the key view [duplicate] (7 个答案) 关
我的程序显示了这个问题。谁能告诉我哪里出了问题? "2016-08-26 17:21:00.548 SegundaTentativa[2347:203583] *** Terminating app
我最近为我的应用实现了一个新 View ,它有一个 UICollectionView 作为要加载的图像的网格: class MemoriesView: UIViewController, UIColl
因此,我正在学习一个教程,并确保我完全按照作者的要求进行操作,并且我的代码抛出了以下错误。 2014-10-01 22:26:14.545 stopwatch2[3503:861733] *** Te
这个问题在这里已经有了答案: Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value co
这个问题已经有答案了: Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value codin
这个问题已经有答案了: Xcode - How to fix 'NSUnknownKeyException', Reason: "… this class is not key value codin
这个问题已经有答案了: Class is not key value coding-compliant [duplicate] (8 个回答) 已关闭 8 年前。 我不断收到此类错误,并且应用程序崩溃
我对 swift 很陌生,我正在 iTunes U 上学习斯坦福大学类(class)。我一直遵循得很好,但我遇到了一个我无法理解的错误: 2015-06-29 18:45:35.080 calcula
我是一名优秀的程序员,十分优秀!