我有一個日曆視圖控制器,它的TKCalender
,並不重要。問題與安裝程序,而不是設置值
我在CalendarMonthViewController
中設置了一個值,我想在另一個ViewController
中調用ViewControllerInsert
。
CalendarMonthViewController.h
@interface CalendarMonthViewController : TKCalendarMonthTableViewController
@property (nonatomic,strong) NSDate *dateSelected; // the value
-(NSDate *)returnDate; // the function to fetch the value
@end
CalendarMonthViewController.m
- (void) calendarMonthView:(TKCalendarMonthView*)monthView didSelectDate:(NSDate*)date{
NSLog(@"Date Selected: %@",date);
self.dateSelected = date; // set the property, at this point self.dataSelect is Valid
[self.tableView reloadData];
}
- (NSDate *)returnDate { // function called by other viewController to get the value
NSDate *dateUserSelected = self.dateSelected;
NSLog(@"%@", self.dateSelected); // logs Null
return dateUserSelected;
}
由於它的日誌空,是空的斷點,數據是某種未設置其當被其他所謂的ViewController ?它的名字就是這樣;
- (IBAction)SeguqInsert:(id)sender {
CalendarMonthViewController *controller = [[CalendarMonthViewController alloc] initWithNibName:nil bundle:nil];
NSDate *selectedDate = [controller returnDate]; // is clearly also Null when its null in the native method
}
你把斷點放在self.dateSelected = date;在 - (void)calendarMonthView:(TKCalendarMonthView *)monthView didSelectDate:(NSDate *)日期方法? –
您正在創建'controller'並立即要求'SeguqInsert:'中的'returnDate',所以'returnDate'總是返回'nil',您的'calendarMonthView:didSelectData:'中的代碼不會運行於'controller '實例。 – yonosoytu
好,我將如何確保它是 –