0

这是 Tapku 的方法,我想从控制器调用它

- (NSDate*) dateSelected{
if(selectedDay < 1 || selectedPortion != 1) return nil;

TKDateInformation info = [monthDate dateInformationWithTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
info.hour = 0;
info.minute = 0;
info.second = 0;
info.day = selectedDay;
NSDate *d = [NSDate dateFromDateInformation:info timeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];


return d;

}

我试图这样称呼它并将其转换为字符串格式。

TKCalendarMonthView *tk=[[TKCalendarMonthView alloc] init];
NSDate *date=tk.dateSelected;// How can I call it?With the debug it shows it's null.
NSDateFormatter *selectedDate=[[NSDateFormatter alloc] init];
[selectedDate setDateFormat:@"yyyy-MM-dd"];
NSMutableString *stringDate=[NSMutableString stringWithFormat:@"%@",[selectedDate stringFromDate: date]]`
4

1 回答 1

0
NSDate *date= [tk dateSelected];

使其成为函数调用(严格来说,向对象发送消息)。点语法仅适用于 getter/setter。我强烈建议先阅读 objc basic。

于 2013-12-21T13:21:33.763 回答