Swift:如何创建带有 Int 值的谓词? [英] Swift: How do I create a predicate with an Int value?
本文介绍了Swift:如何创建带有 Int 值的谓词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在此语句中收到 EXC-BAD-ACCESS 错误:
I am getting an EXC-BAD-ACCESS error on this statement:
var thisPredicate = NSPredicate(format: "(sectionNumber == %@"), thisSection)
thisSection 的 Int 值为 1,当我将鼠标悬停在它上面时会显示值 1.但是在调试区我看到了这个:
thisSection has an Int value of 1 and displays the value 1 when I hover over it. But in the debug area I see this:
thisPredicate = (_ContiguousArrayStorage ...)
另一个使用字符串的谓词显示为 ObjectiveC.NSObject为什么会发生这种情况?
Another predicate using a String shows as ObjectiveC.NSObject Why is this happening?
推荐答案
当您的数据安全或经过消毒时,您可以尝试字符串插值 Swift 标准库参考.看起来像这样:
When your data is safe or sanitized, you might try String Interpolation Swift Standard Library Reference. That would look something like this:
let thisSection = 1
let thisPredicate = NSPredicate(format: "sectionNumber == (thisSection)")
这篇关于Swift:如何创建带有 Int 值的谓词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文