Ok, I'll post the actual code that I am using and is giving the problem. Here it is:
for(NSString *title in oldTasks) { // Get the moc and prepare a fetch request for the required entity NSManagedObjectContext *moc = [self managedObjectContext]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"projects" inManagedObjectContext:moc]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:entityDescription]; // Create a predicate for an array of names. NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title IN %d", oldTasks]; [request setPredicate:predicate]; NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; [request setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]]; // Execute the fetch request put the results into array NSError *error = nil; NSArray *resultArray = [moc executeFetchRequest:request error:&error]; if (resultArray == nil) { // Diagnostic error handling NSAlert *anAlert = [NSAlert alertWithError:error]; [anAlert runModal]; } JGManagedObject *objectToDelete = [resultArray objectAtIndex:0]; // Delete the object. [moc deleteObject:objectToDelete]; } ----- Josh ________________________________ From: Abizern <abiz...@gmail.com> To: Joshua Garnham <joshua.garn...@yahoo.co.uk> Sent: Saturday, 10 October, 2009 13:04:06 Subject: Re: Removing an Object with A Certain Title from an NSTreeController. 2009/10/10 Joshua Garnham <joshua.garn...@yahoo.co.uk> >Hi, > >>I am wondering how I could delete an object depending on it's title for the >>CoreData 'name' property I have. >>To Add an Object I use this code: >>NSManagedObjectContext *moc = [self managedObjectContext]; >>JGManagedObject *theParent = >> [NSEntityDescription insertNewObjectForEntityForName:@"projects" >> inManagedObjectContext:moc]; >>[theParent setValue:nil forKey:@"parent"]; >>// This is where you add the title from the string array >>[theParent setValue:@"myTitle" forKey:@"name"]; >>[theParent setValue:[NSNumber numberWithInt:0] forKey:@"position"]; > >>But I can't seem to find an equivalent function to remove An object. > >>You See, I have an array of strings so I was hoping I could loop through it >>deleting the objects with the title of any of the strings. > >>Cheers. > > Didn't I answer this on Stack Overflow? http://stackoverflow.com/questions/1535778/, even posting a suggested method. You'd be better off posting the actual code that you've tried that you're having trouble with. You've already done so in a comment to me.-- Abizer Send instant messages to your online friends http://uk.messenger.yahoo.com _______________________________________________ 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