Solved

How do I use XML data to populate iOS calendar?

Posted on 2014-02-14
2
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 40074316
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
ID: 40083267
Thank you the example solved my question.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wanted to watch videos in your computer from the bed without the need of standing up and shutting down the computer?  Is your computers operating system Windows XP, Windows Vista or Windows 7?  Do you own a iOS device? If all the answers were y…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

717 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