How to get return value from another class's function in objective-c?

78 views Asked by At

This is the method from Tapku and I want to call it from the controller

- (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;

}

And I'm trying to call it like this and convert it to string format.

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]]`
1

There are 1 answers

2
Max On
NSDate *date= [tk dateSelected];

Makes it a function call (strictly speaking, send the object a message). Dot syntax is for getters/setters only. I strongly suggest reading upon objc basic first.