Re: NSDatePicker : Displaying and binding to nil.
Re: NSDatePicker : Displaying and binding to nil.
- Subject: Re: NSDatePicker : Displaying and binding to nil.
- From: Jonathan Mitchell <email@hidden>
- Date: Tue, 20 May 2014 11:56:06 +0100
On 20 May 2014, at 11:35, Rob Petrovec <email@hidden> wrote:
> I haven’t looked at your code, but why not use a nil placeholder value when binding? Pass an options dictionary with a key / value pair of NSNullPlaceholderBindingOption / <the value you want to use when nil> to the -bind:… method, or specify the value for the nil placeholder in the nib. Something like:
>
> [datePicker bind: NSValueBinding
> toObject: self
> withKeyPath: @“myDate"
> options: @{ NSNullPlaceholderBindingOption, [NSDate futureDate] }];
>
> Hope that helps...
>
> —Rob
I think the fundamental issue is that NSDatePicker always displays a date regardless of -dateValue or the bound value.
Using a [NSDate distantFuture] placeholder results in the NSDatePicker displaying 01/01/4001.
In my app some dates are optional/initially empty and hence bound to nil. I need the date picker to reflect this.
The TFDatePicker subclass observes a nil -dateValue or bound value and manages the draw state to represent this.
The subclass also provides a popover that enables the user to reset the date picker to nil if required.
Jonathan
_______________________________________________
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