IOS/xcode/coredata: Implement calendar control using core data -
ios newb here trying implement open source calendar control maday in project data stored in core data. calendar control not provide documentation accessing core data.
i guessing need create nsarray after pulling events core data corresponds "events" array below. all? , if so, how do that?
thanks suggestions.
here datasource code library:
- (nsdate *)nextdayfordate:(nsdate *)date; - (nsarray *)eventkiteventsfordate:(nsdate *)date; - (nsarray *)eventkiteventstomaevents:(nsarray *)eventkitevents; @property (readonly) ekeventstore *eventstore; @end @implementation maeventkitdatasource - (nsarray *)dayview:(madayview *)dayview eventsfordate:(nsdate *)date { return [self eventkiteventstomaevents:[self eventkiteventsfordate:date]]; } - (nsarray *)weekview:(maweekview *)weekview eventsfordate:(nsdate *)date { return [self eventkiteventstomaevents:[self eventkiteventsfordate:date]]; } - (ekeventstore *)eventstore { if (!_eventstore) { _eventstore = [[ekeventstore alloc] init]; } return _eventstore; } - (nsdate *)nextdayfordate:(nsdate *)date { nsdatecomponents *components = [[nsdatecomponents alloc] init]; [components setday:1]; return [current_calendar datebyaddingcomponents:components todate:date options:0]; } - (nsarray *)eventkiteventsfordate:(nsdate *)startdate { nspredicate *predicate = [self.eventstore predicateforeventswithstartdate:startdate enddate:[self nextdayfordate:startdate] calendars:nil]; nsarray *events = [self.eventstore eventsmatchingpredicate:predicate]; return events; } - (nsarray *)eventkiteventstomaevents:(nsarray *)eventkitevents { nsmutablearray *events = [[nsmutablearray alloc] init]; (ekevent *event in eventkitevents) { maevent *maevent = [[maevent alloc] init]; maevent.title = event.title; maevent.start = event.startdate; maevent.end = event.enddate; maevent.allday = event.allday; maevent.backgroundcolor = [uicolor colorwithcgcolor:event.calendar.cgcolor]; maevent.textcolor = [uicolor whitecolor]; [events addobject:maevent]; } return events; }
i haven't worked myself framework, far can see code , eventkit
documentation, has own store doesn't require further core-data handling.
so: read documentation understand ;)
Comments
Post a Comment