iphone: setObject:forKey: 和 setValue:forKey: 在将条目添加到可变字典中有什么区别
<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>来自文档:</p>
<p> <a href="https://developer.apple.com/documentation/foundation/nsmutabledictionary/1416335-setvalue?language=objc" rel="noreferrer noopener nofollow"><code>setValue:forKey:</code></a> </p>
<blockquote>
<p>Discussion<br/>
This method adds value and key to the dictionary using setObject:forKey:, unless value is nil in which case the method instead attempts to remove key using removeObjectForKey:.</p>
</blockquote>
<p> <a href="https://developer.apple.com/documentation/foundation/nsmutabledictionary/1411616-setobject?language=objc" rel="noreferrer noopener nofollow"><code>setObject:forKey:</code></a> </p>
<blockquote>
<p>Important<br/>
Raises an NSInvalidArgumentException if aKey or anObject is nil. If you need to represent a nil value in the dictionary, use NSNull.</p>
</blockquote>
<p>如果字典中已经存在aKey,则向字典的该键的先前值对象发送一条释放消息,并用一个对象代替它。</p></p>
<p style="font-size: 20px;">关于iphone: setObject:forKey: 和 setValue:forKey: 在将条目添加到可变字典中有什么区别,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/6161492/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/6161492/
</a>
</p>
页:
[1]