Re: NSController and NSCalendarDate
Re: NSController and NSCalendarDate
- Subject: Re: NSController and NSCalendarDate
- From: Scott Anguish <email@hidden>
- Date: Tue, 23 Nov 2004 19:42:22 -0500
On Nov 23, 2004, at 6:13 PM, Andrew Salamon wrote:
I would like to hook a number of controls up to a single
NSCalendarDate: year, month, day, hour, minute, am/pm, date, time
(much like in iCal). Simply binding the text fields to the data
results in fields being reset to some default date when another field
is modified by the user. E.g. set the time and the date resets to some
default value and vice-versa.
yep, weirdness..
Right now what I have is a set of alternate methods for getting and
setting the individual components of the date variable. That works,
but has to be repeated for each NSCalendarDate. This seemed to me to
be a great place to insert an NSController subclass. What I thought I
would do is add a bunch of additional bindings to the subclass. One
for each piece of the date. Then each field would be bound to one of
the alternate bindings rather than 'selection'.
I think you'd want to use NSObjectController as the base for this,
not NSController. but I don't see a controller class even being
related...
If NSCalendarDate was KVC compliant for the required fields this
would be easy... alas, it's not mutable, so you've another whole issue.
My suggestion would be to create your own CalendarDate class that
is KVC compliant for all the fields, and can return
an NSCalendarDate.
Hrm.. I suppose you could you a value transformer that converts an
NSCalendarDate to an NSMutableDictionary (and the reverse) and set the
Object Controller's content to the NSCalendarDate using that Value
Transformer...
Unfortunately, I have no idea how to go about doing that. Especially
if I want the bindings to show up in IB. And I haven't been able to
find any documentation on it.
for the bindings to show up in IB, you'd need to create a palette.
but if you only want it to be a model object (which is what you want I
think) you'd not need to do anything like that.. just set it as the
content object for the controller
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden