Solved

How do I use XML data to populate iOS calendar?

Posted on 2014-02-14
2
476 Views
Last Modified: 2014-05-22
I am adding calendar appointments to the native iOS calendar by retrieving XML data from a database.  The XML data is similar to this.
<draw>
<date>2014-02-11</date>
<starttime>08:00:00</startttime>
<endtime>12:00:00</endtime>
<street>509 NORTH 44TH</street>
</draw>
<draw>
<date>2014-02-11</date>
<starttime>16:00:00</startttime>
<endtime>18:00:00</endtime>
<street>4107 BLOSSUMWOOD DR</street>
</draw>

I am wanting to use the date, start time and end time to set the appointment and use the address as the title.

My Xcode looks like this. I have commented the sections I need populated from XML.
-(IBAction)saveEvent:(id)sender

{
    today = [NSDate date];
    messageDate = date;
    store=[[EKEventStore alloc] init];
    EKEvent *addEvent=[EKEvent eventWithEventStore:store];
    addEvent.title=@"1202 Test Way";//needs to be street from XML.
    addEvent.startDate=today;//needs to be date and starttime from XML.
    addEvent.endDate=today;//needs to be date and endtime from XML.
    [addEvent setCalendar:[store defaultCalendarForNewEvents]];
    addEvent.alarms=[NSArray arrayWithObject:[EKAlarm    alarmWithAbsoluteDate:addEvent.startDate]];
    [store saveEvent:addEvent span:EKSpanThisEvent error:nil];
   
   
}
0
Comment
Question by:aduvall
2 Comments
 
LVL 19

Accepted Solution

by:
darbid73 earned 500 total points
Comment Utility
Unless I am mistaken your issue is converting your XML date and times to something you can use for the EventStore.

Thus you need to convert a date/time string into a NSDate.  Once you know this there are many examples.

This is but one example.

Here is more less specific Apple Developer information on what you need to do.

The one thing I am missing from your xml is what time this is? To create a NSDate you are going to need to tell iOS where the time comes from, is the XML based on the users local time or is the XML based on for example GMT.  This will be needed otherwise you will get strange results.
0
 

Author Comment

by:aduvall
Comment Utility
Thank you the example solved my question.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now