views:

135

answers:

2

I have an NSArray of Strings and what I want to do is create a new CalTask (for the calendar store) for every String, I want the Name of the task to be the string that is being added, the Priority and Due Date to be set in the code.

For example I have an array with the Strings To-Do 1, TD 2, TD 3. So I want to create 3 CalTasks, the first one with the Name To-Do 1 and the second with the name TD 2 etc. See what I'm talking about. But I want all the Priorities and Due Dates to be the Same.

+2  A: 

Have a look at the Calendar Store Programming Guide.

Georg
It tells you how to create a Task, but not specifically with an Array.
Joshua
Have you ever programmed anything in Objective-C?
Georg
@Joshua: how hard is it to loop through an array? How hard is it to look at the example code on how to create a Task? http://bit.ly/nYcjp
Dave DeLong
Yes, I have. I looked at the example code thank you very much. But I didn't know you could loop through an array.
Joshua
+2  A: 
Tim
It doesn't seem to work, I get no errors in XCode, but after triggering the Action there are still no new tasks/to-dos in iCal.
Joshua
Make sure you do error-handling at the marked point - if the calendar store doesn't get updated, this sample code will produce no messages. Also possibly add more `NSLog()` statements throughout the code to see what's happening where. Once you've done that, please provide more specific info about what exactly isn't working.
Tim
Ok. I put a NSLog message saying Error where you put `// Do error-handling`. And i got 3 Log messages saying error, one for each string in the array.
Joshua
@Joshua, I've changed the `Save task` section. See if that gives you an idea about how to use `NSError`s.
Abizern
Ah. It says, http://snapplr.com/9xpk.
Joshua
OK. This would be my bad: the `calendar` object I created wasn't valid to add tasks to. Instead, what you should do is pull a calendar from the store. I've updated the answer to correct.
Tim
Works Perfectly! Thanks very much!
Joshua