How to refresh/update Core Data transient property?

Discussion in 'iOS Programming' started by mdhansen5, Aug 4, 2012.

  1. macrumors member

    Nov 22, 2010
    I'm using a core data, NSFetchedResultsController UITableView, with a transient NSDate attribute. The main reason I have this as a transient property is so my UITableView entries get put into sections based on NSDate, but can move between the sections when the date changes.

    So far it seems to work great, but it only updates/refreshes (I'm really new to this, so I don't know if I'm using the correct terminology, sorry!) when I either close the app and kill it from multitasking, or re-run it through Xcode. If I don't do that, the items don't change and aren't put into their correct sections. Is there a way to manually get it to refresh so the user doesn't need to do that to get it to run right?

    Thank you!
  2. macrumors newbie


    Jul 10, 2012
    It sounds like you are not saving your managedObjectContext.

    After you update one of your entity's date attribute, save the managed object context.

    NSError * error = nil;
    [your_entity.managedObjectContext save:&error];
  3. macrumors 68030


    Jan 19, 2006
    Transient properties don't save to the persistent store. That is the point of them being transient, your saying to the store don't bother saving this data i can recreate it as needed.

    There are a couple of ways to recreate them. One which might be simplish is to create a sub-class for your Entity. Then you can overwrite the
    method to repopulate the transient fields as the entity gets pulled from the store.

    Trying to hunt round for a good tutorial. Will post later if i find.
    The other useful method that could be of interest is
    which you could use to set the value went you create the object.

Share This Page