Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSdateformatter and table.. just cant get it working

NSdateformatter and table.. just cant get it working
Thread Tools
KeithOP
Fresh-Faced Recruit
Join Date: Aug 2002
Status: Offline
Reply With Quote
Sep 29, 2002, 12:17 AM
 
Hi all,

Just want to accept dates of the format Sat, 16 Mar 2002 10:44:24 -0700 and have dateformatter format them all to say, 16/03/2002

I setup a textfield and got it working fine in there just with IB and a format string... no problem.

So went to my app which has an outlineview with 3 columns. clicked on the header of the third column and inserted a dataformatter in IB. Could change the string and see the sample data in IB in the table change to be the right format. So far so good.

When I run the app though, that column stays blank. (other 2 columns work fine still). Remove the formatter and the raw date goes in no problem.

To help debug, I set objectValueForTableColumn to return "12/12/2002" when asked for data for that column... knowing it was a valid date I could easily setup for... still blank (tried turning on natural language and returning yesterday.. same result).

I even tried putting a normal number formatter on and gave it "12" as the data... and still blank

What am I missing?

Thanks all,
Keith
     
tobli
Forum Regular
Join Date: Oct 2001
Location: Sweden
Status: Offline
Reply With Quote
Sep 29, 2002, 02:59 PM
 
Why not return a NSDate object?
     
lindberg
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Sep 30, 2002, 11:27 PM
 
NSDateFormatter expects NSCalendarDate instances as its "object value", and formats them to a string for display. Going the other way, it takes a string from the user and creates an NSCalendarDate instance to be stored in the underlying model. So, in your objectValueForTableColumn: method, return an NSCalendarDate instance, and in setObject:forTableColumn:, expect an NSCalendarDate instance to be passed to you, not a string.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 07:10 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,