Hi, Thanks, It works now I've fixed the warnings.
Cheers. ________________________________ From: Stamenkovic Florijan <flor...@mac.com> To: Joshua Garnham <joshua.garn...@yahoo.co.uk> Cc: cocoa-dev <cocoa-dev@lists.apple.com> Sent: Thursday, 1 October, 2009 13:32:20 Subject: Re: Deleting CalTasks through an Array. Hi Joshua, You're welcome, but you need to also learn some stuff on your own. 1. Browse the docs: NSArray does not have a contains: method, it has a containsObject: method. My mistake, but one that's easy to spot. 2. Check the method signatures for CalCalendar store. I believe I gave you the right ones (in which case your imports are somehow messed up). If I gave you the wrong ones, change them. Also please keep all communication *on* the list. F On Oct 01, 2009, at 01:54, Joshua Garnham wrote: > Thanks! > I've got a few warnings though : http://snapplr.com/zm6w. > Especially with the NSPredicate. > > From: Stamenkovic Florijan <flor...@mac.com> > To: Joshua Garnham <joshua.garn...@yahoo.co.uk> > Cc: cocoa-dev@lists.apple.com > Sent: Wednesday, 30 September, 2009 20:24:59 > Subject: Re: Deleting CalTasks through an Array. > > > On Sep 30, 2009, at 12:32, Joshua Garnham wrote: > > > I have an Array of strings and want to remove CalTasks with titles of any > > of the strings. > > I know I can loop through a array with > > > > for(NSString *title in array) { > > } > > > > and delete tasks with > > > > removeTask:title error:nil > > But it won't let me delete a CalTask object with the strings from the Array > > instead it wants the actual CalTask object.How would I delete a CalTask > > object by matching it's title to a string in an array? > > Joshua, > > You need to use CalCalendarStore's method "taskPredicateWithCalendar", > passing it all calendars to get the tasks, then compare titles and delete if > necessary. > > // make a predicate for all tasks > NSPredicate* allCalendarsTaskPredicate = [CalCalendarStore > taskPredicateWithCalendar:[CalCalendarStore calendars]]; > > // fetch all the tasks > NSArray* allTasks = [[CalCalendarStore defaultCalendarStore] > tasksWithPredicate:allCalendarsTaskPredicate]; > > // delete them > for(CalTask* task in allTasks) > if([arrayOfTitles contains:tast.title]) > // delete task > > More or less... Sorry for the typos, I am writing directly to mail. > > What would be more efficient and *might* work is creating a compound > predicate out of the allTasks predicate and a predicate that would > discriminate tasks that don't have a matching title. However, I am not sure > that predicate would work with the CalendarStore. Something to explore if the > performance is an issue. > > HTH > F > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com