ios - 条件绑定(bind)必须有 Optional 类型,而不是 'String'
<p><div>
<aside class="s-notice s-notice__info post-notice js-post-notice mb16"role="status">
<div class="d-flex fd-column fw-nowrap">
<div class="d-flex fw-nowrap">
<div class="flex--item wmn0 fl1 lh-lg">
<div class="flex--item fl1 lh-lg">
<b>这个问题在这里已经有了答案</b>:
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>它指出使用 if 条件是不必要的,因为 'productName' 不是可选的。</p>
<p>您可以直接将值添加到标签中。 </p>
<pre><code>self.productName.text = productData.product.productName //Product name is not optional
</code></pre>
<p>当您尝试获取可选值时使用可选链。
例如,如果要获取标签的文本,则需要 if 条件。</p>
<pre><code>if var text = self.productName.text { //Text in label is optional
print(text)
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 条件绑定(bind)必须有 Optional 类型,而不是'String',我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/55327489/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/55327489/
</a>
</p>
页:
[1]