Monotouch EKEvent Notes not being saved
What am I doing wrong here? currentEvent.Title prints correctly. currentEvent.Notes is always blank..
public void CalendarEvents()
{
EKEventStore store = new EKEventStore();
EKCalendar calendar = store.DefaultCalendarForNewEvents;
// Query the event
if (calendar != null)
{
// Add a new event
EKEvent newEvent = EKEvent.FromStore(store);
newEvent.Title = "Lunch at McDonalds";
newEvent.Calendar = calendar;
newEvent.StartDate = DateTime.Now.Date;
newEvent.EndDate = DateTime.Now.Date.AddDays(4);
newEvent.Availability = EKEventAvailability.Free;
newEvent.Notes = "hello";
store.SaveEvent(newEvent, EKSpan.ThisEvent, new IntPtr());
// Searches for every event in the next year
NSPredicate predicate = store.PredicateForEvents(NSDate.Now,DateTime.Now.AddDays(360),new EKCalendar[] {calendar});
store.EnumerateEvents(predicate, delegate(EKEvent currentEvent, ref bool stop)
{
开发者_如何学Python // Perform your check for an event type
Console.WriteLine(currentEvent.Title);
Console.WriteLine(currentEvent.Notes);
});
}
}
The API likely has changed because the above won't compile 'as-is'. So I updated your:
store.SaveEvent(newEvent, EKSpan.ThisEvent, new IntPtr());
to
NSError error;
store.SaveEvent(newEvent, EKSpan.ThisEvent, out error);
Otherwise, using the latest MonoTouch, I get both strings displayed in the "Application Output" (app running on device).
Lunch at McDonalds
hello
Maybe that was fixed when the API was modified ?
精彩评论