setObjectValue Problem

Discussion in 'iPhone/iPad Programming' started by kwjohns, Dec 29, 2008.

  1. macrumors 6502a

    kwjohns

    Joined:
    Jul 4, 2007
    #1
    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.
     
  2. thread starter macrumors 6502a

    kwjohns

    Joined:
    Jul 4, 2007
    #2
    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?
     

Share This Page