我试图从一行中获取值,将其转换为字符串,然后检查该字符串是否在数组中。到目前为止,我有这个:
<component name="libraryTable">
<library name="android-mail-1.5.5">
<CLASSES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.sun.mail/android-mail/1.5.5/53a2f927b235acb565dbe9314ececfb7e6d43020/android-mail-1.5.5.jar!/"/>
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/.gradle/caches/modules-2/files-2.1/com.sun.mail/android-mail/1.5.5/3bc78121c0f32347049349f999ca9a3039f6d64e/android-mail-1.5.5-sources.jar!/"/>
</SOURCES>
</library>
</component>
但出于某种原因,它会继续打印我的变量 let row: IntRow? = form.rowBy(tag: "devicefield")
let stringvalue = String(describing: row?.value)
if (row?.value) != nil
{
if tableDevices.contains("\(stringvalue)")
{
self.dismiss(animated: false, completion: nil)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "filterData"), object: nil)
}
else
{
SCLAlertView().showError("Error", subTitle: "\(stringvalue) does not exist at your facility")
return
}
}
作为可选项。
答案 0 :(得分:1)
row?.value是可选的。这很明显,因为你看到&#34;?&#34;。因此,您正在使用的打印命令只是打印出它是可选的。字符串不是可选的,变量是。你可以得到一个像这样的新变量:
if let printableRowNumberAsInt = row?.value {
// do your stuff like...
print("\(printableRowNumberAsInt)")
}