objective c - Add location to EKEvent IOS Calendar -


how add location not nsstring latitude , longitude ,so shows map in calendar?

<ekcalendaritem>   

https://developer.apple.com/library/ios/documentation/eventkit/reference/ekcalendaritemclassref/index.html#//apple_ref/occ/instp/ekcalendaritem/location

@property(nonatomic, copy) nsstring *location; 

code :

 ekeventstore *store = [[ekeventstore alloc] init]; [store requestaccesstoentitytype:ekentitytypeevent completion:^(bool granted, nserror *error) {     if (!granted) { return; }     ekevent *event = [ekevent eventwitheventstore:store];     event.title = @"event title";     event.startdate = [nsdate date]; //today     event.enddate = [event.startdate datebyaddingtimeinterval:60*60];  //set 1 hour meeting     event.notes=@"note";     event.location=@"eiffel tower,paris"; //how add lat & long / cllocation?     event.url=[nsurl  urlwithstring:shareurl];     [event setcalendar:[store defaultcalendarfornewevents]];     nserror *err = nil;     [store saveevent:event span:ekspanthisevent commit:yes error:&err];     nsstring *savedeventid = event.eventidentifier;  //this can access event later }]; 

example

the property structuredlocation available on ios 9, though ekevent documentation doesn't mention it, structuredlocation exist in ekevent public header file, , can check inside xcode. no need use kvc set after ios 9.

swift version follows:

let location = cllocation(latitude: 25.0340, longitude: 121.5645) let structuredlocation = ekstructuredlocation(title: placename)  // same title ekevent.location structuredlocation.geolocation = location ekevent.structuredlocation = structuredlocation 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -