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 posi开发者_开发知识库tive I've properly linked datePicker to the UIDatePicker element in Interface Builder.
Thanks!
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.
精彩评论