Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
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:

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

The iPhone SDK has a problem with:

Code:
[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.
 

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
From another thread that just popped up, I noticed the person used the following:

Code:
// 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?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.