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.

https://developer.apple.com/library/prerelease/ios/documentation/eventkit/reference/ekeventstoreclassref/index.html#//apple_ref/occ/instm/ekeventstore/savecalendar:commit:error:

so: read documentation understand ;)


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -