Hi,
I have a NSMutableArray that contains all the calendars on my system (as CalCalendar
objects):
NSMutableArray *calendars = [[CalCalendarStore defaultCalendarStore] calendars];
I want to remove from calendars
any CalCalendar
objects whose title does not include the string @"work"
.
I've tried this:
for (CalCalendar *cal in calendars) {
// Look to see if this calendar's title contains "work". If not - remove it
if ([[cal title] rangeOfString:@"work"].location == NSNotFound) {
[calendars removeObject:cal];
}
}
The console is complaining that:
*** Collection <NSCFArray: 0x11660ccb0> was mutated while being enumerated.
And things go bad. Obviously it would seem you can't do what I want to do this way so can anyone suggest the best way to go about it?
Thanks,