Thursday, 7 March 2013

How to delete attributes value for a Entity in CORE DATA in IOS



    NSManagedObjectContext *context;
    
    NSFetchRequest * request = [[NSFetchRequest alloc] init];
    [request setEntity:[NSEntityDescription entityForName:@"YourEntityClass" inManagedObjectContext:context]];
    [request setIncludesPropertyValues:NO]; //only fetch the managedObjectID
    
    NSError * error = nil;
    NSArray * formDataDel = [context executeFetchRequest:request error:&error];
    
    //error handling goes here
    for (NSManagedObject * data in formDataDel) 
    {
        [context deleteObject:data];  //DELETING HERE
    }
    NSError *saveError = nil;
    [context save:&saveError];