views:

37

answers:

1

I'm using a UIDatePicker in time mode to get the time. I'm trying to display the time selected in a label. The following code doesn't work

NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"h:mm a"];

label.text = [outputFormatter stringFromDate:self.datePicker.date];

[outputFormatter release];
+1  A: 

That code looks fine to me. Did you double check that your label/datepicker are linked up correctly (either through IB or however you created them)? Also, in what way specifically does the code not work?

Sam
You were right about the link. I forgot to make the link in IB. The code works.
awakeFromNib