• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Deleting CalTasks through an Array.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deleting CalTasks through an Array.


  • Subject: Re: Deleting CalTasks through an Array.
  • From: Joshua Garnham <email@hidden>
  • Date: Thu, 1 Oct 2009 08:19:52 -0700 (PDT)

Hi,

Thanks, It works now I've fixed the warnings.

Cheers.


________________________________
From: Stamenkovic Florijan <email@hidden>
To: Joshua Garnham <email@hidden>
Cc: cocoa-dev <email@hidden>
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 <email@hidden>
> To: Joshua Garnham <email@hidden>
> Cc: email@hidden
> 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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Re: Deleting CalTasks through an Array. (From: Stamenkovic Florijan <email@hidden>)

  • Prev by Date: Re: Cannot get pixel color from NSBitmapImageRep
  • Next by Date: Re: Releasing NSSearchPathForDirectoriesInDomain causes crash
  • Previous by thread: Re: Deleting CalTasks through an Array.
  • Next by thread: Re: NSValueTransformer problem with NSTextField update
  • Index(es):
    • Date
    • Thread