• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bindings - custom null value placeholder for text field with date formatter?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bindings - custom null value placeholder for text field with date formatter?


  • Subject: Bindings - custom null value placeholder for text field with date formatter?
  • From: Jim Correia <email@hidden>
  • Date: Thu, 5 Jan 2006 23:44:00 -0500

I have an NSTextField bound to a key which provides an NSDate. The date represents the last time something happened. A null value means that action has never taken place. If the action has never taken place, I'd like the field to say "Never" and be in regular black text (not the usual gray null value placeholder color.)

Is there some way I can do this with the bindings system? I feel like I'm fighting the framework, so I must be doing something wrong.

What I've tried so far:

• Bind the text field's value (though the controller) to the date attribute. If I don't attach a formatter in IB, I can provide a null value placeholder of "Never", but it shows up in gray, and I'd rather it be black. (I later attach a formatter by hand so that the date value is formatted. This seems superficially wrong, since I've subverted the checks IB seems to do in case 2.)

• The same as the above, but attach a date formatter. Now the null value placeholder field in IB says <date value>. I can't seem to get it to accept a date value if I type one in the field, and that isn't what I want anyway.

* The same as above, but supply a custom formatter which returns "Never" from -stringForObjectValue:. The formatter doesn't seem to get this message in the case of a nil value.

What is the right (or any way, even ugly) way to solve this problem with bindings?

Or must I do things "by hand" for this field because I have somewhat special needs?

Thanks,
Jim _______________________________________________
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


  • Follow-Ups:
    • Re: Bindings - custom null value placeholder for text field with date formatter?
      • From: Casey Fleser <email@hidden>
  • Prev by Date: Re: Binding to to-one relationship
  • Next by Date: Custom Views/Controls
  • Previous by thread: Re: Binding to to-one relationship
  • Next by thread: Re: Bindings - custom null value placeholder for text field with date formatter?
  • Index(es):
    • Date
    • Thread