?
Solved

How do I use XML data to populate iOS calendar?

Posted on 2014-02-14
2
Medium Priority
?
511 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 2000 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

Technology Partners: 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

I recently went through the process of creating an installable image of an iPhone mobile app (an .ipa file) that beta testers could load onto their test devices. The process involved quite a few steps, but both Appcelerator and Diawi.org had decent …
How to take pictures with depth using iOS 10
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

770 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