<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey there,<div class=""><br class=""></div><div class="">I have a model that contains an optional NSNumber.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">@objc</span>(Model) <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">final</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> Model : <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSObject</span> {</div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; line-height: normal;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">dynamic</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> someNumber: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">NSNumber</span>?</div></div><div class=""><span style="font-family: Menlo; font-size: 11px;" class="">}</span></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I now bind such en object to an NSObjectController, </div><div class="">and bind the <i class="">value</i> binding of an NSTextField to the object controller's <i class="">selection.someNumber</i> key path.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">After loading, the number is properly displayed.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #6389ff" class=""><b class="">(lldb) </b></span><b class="">e/x someNumber!</b></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">(__NSCFNumber *) $R0 = 0x0000000000002a57</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #6389ff" class=""><b class="">(lldb) </b></span><b class="">e/d someNumber!.intValue</b></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">(Int32) $R1 = 42</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">However, when I change the entry, the number is replaced by a string.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #6389ff" class=""><b class="">(lldb) </b></span><b class="">e/x </b><b class="">someNumber</b><b class="">!</b></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">(NSTaggedPointerString *) $R2 = 0x0000000000323425 "42"</div></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #6389ff" class=""><b class="">(lldb) </b></span><b class="">e/d </b><b class="">someNumber</b><b class="">!.intValue</b></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">(Int32) $R3 = 42</div></div><div class=""><br class=""></div><div class="">Now, stuff like <i class="">==,</i> <i class="">isEqualToNumber, </i>and <i class="">compare</i> obviously no longer works.</div><div class=""><b class="" style="font-family: Menlo; font-size: 11px;"><font color="#ff4013" class="">-[NSTaggedPointerString isEqualToNumber:]: unrecognized selector sent to instance 0x303425</font></b></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">It seems like the NSNumber variable morphed into a NSString.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">What's going on here?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Etan</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">PS: The NSTextField documentation clearly states that NSNumbers are supported to be bound as the value:</div><div class=""><br class=""></div><div class=""><h3 class="tight jump" style="margin-top: 2em; margin-bottom: -0.25em; font-size: 19px; font-weight: 400; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; background-color: rgb(255, 255, 255);">value</h3><p style="margin-top: 1.083em; margin-bottom: 0.833em; font-size: 13px; line-height: normal; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; background-color: rgb(255, 255, 255);" class="">An NSString or NSNumber that is displayed as the content of the <code style="font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102);" class="">NSTextField</code>. </p><div class="availabilityList" style="border: 0px; margin-top: 0.417em; margin-bottom: 0px; font-size: 13px; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; background-color: rgb(255, 255, 255);"><span style="font-weight: 700;" class="">Availability:</span><div class="availabilityItem" style="margin-top: -1.25em; margin-bottom: 1.25em; padding-left: 6.5em;">Available in OS X v10.3 and later.</div></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>