Solved

How do I use XML data to populate iOS calendar?

Posted on 2014-02-14
2
498 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

Suggested Solutions

Title # Comments Views Activity
File attachment not working in email on iPhone 7 9 105
iPhone excel activation issues 11 141
Can someone explain the following statement in C? 4 67
maximize the sum of fractions 33 70
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The release of the iPhone 6 and the iPhone 6 Plus was extremely successful for Apple. However when iOS 8.1 was introduced, many iPhone users complained of quick battery drainage. Without even knowing, you may be unnecessarily using up your battery p…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

739 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