How to refresh/update Core Data transient property?

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

  1. mdhansen5 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. SplitIt! 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. MattInOz 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.
  4. ngergo100 macrumors newbie

    Sep 4, 2016
  5. bjet767 macrumors 6502a

    Oct 2, 2010
    Did you try to reload data?

    Or do a update to the view such as re-display?

    Since your question indicates a change was made but not shown until the app is restarted. This indicates to me you need to add some sort of update to you table view delegate.

    The best place to find answers is here, and I've included a thread about a similar problem: is the goto place for iOS programming discussions.

Share This Page