0

I have a app that parses all my data from my web service as soon as the app is loaded however I want to add an IBACTION (Button) that will delete all of the data from the coredata and reparse the information (therefore updating the data base) - like a Refresh Button.

The Method that call the parsing is:

- (void)getRssData 
{
   self.webServiceAndParser =  [[LukesParser alloc] initWithDelegate:self]; 
    [self.webServiceAndParser getAllData];
}

The core data method im using the build the object in my fetch results controller is:

- (void)insertNewObject
{
    // Create a new instance of the entity managed by the fetched results controller.
    NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
    NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];
    NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];
    [newManagedObject setValue:[NSDate date] forKey:@"timeStamp"];

    // Save the context.
    NSError *error = nil;
    if (![context save:&error])
    {

        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
        abort();
    }
}

any ideas?

Bradley
  • 617
  • 2
  • 11
  • 26

1 Answers1

0

If you're deleting all the data in your Core Data persistent store, then see Delete/Reset all entries in Core Data? for some possible approaches.

Community
  • 1
  • 1
Scott Forbes
  • 7,397
  • 1
  • 26
  • 39