iosobjective-csyntaxcastingmbcalendarkit

What does "[self data][date]" mean?


Can any one just tell me what the below code in iOS mean? Its a piece of code from MBCalendarKit.

@property (nonatomic, strong) NSMutableDictionary *data;

- (NSArray *)calendarView:(CKCalendarView *)calendarView eventsForDate:(NSDate *)date
{
    return [self data][date];
}

How does the above function return an NSArray when the global data is an NSMutableDictionary and the local date is NSDate?

And what does [self data][date] mean?


Solution

  • If data is an NSDictionary then it means exactly the same thing as [data objectForKey:date]. That syntax was introduced a couple of years ago — ideally read the whole thing but if in a hurry then jump to 'Object Subscripting'.