开发者

objective-C : Reset tableview loaded with feltching objects (core data)

开发者 https://www.devze.com 2022-12-24 18:41 出处:网络
i have a tableview application loaded with core data feltching objects and i wanna know if it is possible to reset the table with a simple button. Thanks

i have a tableview application loaded with core data feltching objects and i wanna know if it is possible to reset the table with a simple button. Thanks

code to add an object :

    NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[fetchedResultsController fetchRequest] entity];
NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjec开发者_如何学运维tContext:context];




[newManagedObject setValue:string forKey:@"timeStamp"];

my code to delete (one) object:

    NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];
    [context deleteObject:[fetchedResultsController objectAtIndexPath:indexPath]];

i want a button that reset the tableview and delete everything thanks


Change the datasource to an empty one, and use the reloadData method to reload the table data from that datasource?

0

精彩评论

暂无评论...
验证码 换一张
取 消