View Full Version : setObjectValue Problem

Dec 29, 2008, 08:33 PM
I am currently reading Cocoa Programming for Mac OS X (3rd Ed.) and as a little side project, I am trying to convert the apps I create following through this book into iPhone apps if possible. I just started and I am trying to convert over the Generator app. A problem I am having is with the following code:

- (void)awakeFromNib
NSCalendarDate *now;
now = [NSCalendarDate calendarDate];
[textField setObjectValue:now];

The iPhone SDK has a problem with:

[textField setObjectValue:now];

and I get the error:

warning 'UILabel' may not respond to '-setObjectValue:'

I'm having an issue determining what to run here to display the date/time into the label.

Dec 29, 2008, 08:56 PM
From another thread that just popped up, I noticed the person used the following:

// Create the date formatter
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"EEEE, MMMM d, YYYY"];

// Set the dateLabel on the view to today's date using the date formatter
NSDate *today = [NSDate date];
dateLabel.text = [dateFormatter stringFromDate:today];

Is there a way to display it without the formatter for explanation's sake as the previous code or is it required?