Ian McIntyre Silber
Ian McIntyre Silber

Reputation: 5663

Get UIDatePicker variable from another view

I'm sure I have something dumb wrong, but I'm trying to pass the data set in a UIDatePicker from one view to another (I'm using the Utility Template in Xcode).

I've written out all of the pertinent code below.


FlipsideViewController.h

@interface FlipsideViewController : UIViewController {
    IBOutlet UIDatePicker *datePicker;
}

@property(nonatomic, retain) IBOutlet UIDatePicker *datePicker;

FlipsideViewController.m

@synthesize datePicker;

mainViewController.m

NSDate *time = flipsideViewController.datePicker.date;

Logging time returns null.

Also, I'm positive I've properly linked datePicker to the UIDatePicker element in Interface Builder.

Thanks!

Upvotes: 0

Views: 213

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 72991

flipsideViewController.datePicker.date may not exist by the time you go back to mainViewController. You need to set it before you release or return from the FlipViewController view.

Upvotes: 1

Related Questions