Re: IBOutlet & NSNumber
Re: IBOutlet & NSNumber
- Subject: Re: IBOutlet & NSNumber
- From: Randy Widell <email@hidden>
- Date: Sat, 13 Oct 2012 21:17:38 -0700
Wow. Woah. OK, sorry my ignorance offends. What in the world was I trying to do…I was trying to bind the selection index of a NSComboBox to a NSNumber because the Apple Cocoa bindings document for NSComboBox says the value can be bound to a NSNumber.
Using -init didn't seem so nonsensical to me. It could it init with 0. It could init with NaN. But, you're right, -init is not listed in the NSNumber class reference and that should have been a clue.
Anyway, cool, I just decided to use -indexOfSelectedItem on a NSComboBox outlet when the sheet finishes.
On Oct 13, 2012, at 8:52 PM, Ken Thomases <email@hidden> wrote:
> On Oct 13, 2012, at 9:49 PM, Randy Widell wrote:
>
>> Quick question… For some reason I cannot find an answer.
>>
>> I have a NSWindowController subclass and I want to bind the selection index of a NSComboBox to a NSNumber that is an IBOutlet of the NSWindowController subclass. I have a NSNumber object in the window's XIB and the object is linked to the outlet in the subclass, but the outlet is always nil.
>>
>> Is there something special about NSNumber? Other object types seem to work.
>
> How could that NSNumber be initialized? It could only be via -init. A quick test here shows that [[NSNumber alloc] init] returns nil. I.e. it fails, because that's a nonsensical thing to do.
>
> So is putting an NSNumber in a NIB. What in the world are you trying to do? In general, it makes no sense to put things other than views or controller objects into NIBs. NSNumbers are value objects, suitable for the model layer of your app.
>
> Regards,
> Ken
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden