Swift:如何创建具有Int值的谓词? [英] Swift: How do I create a predicate with an Int value?

查看:58
本文介绍了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?

推荐答案

当您的数据安全或卫生后,您可以尝试使用字符串插值快速标准库参考。看起来像这样:

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆