mplappert
mplappert

Reputation: 1324

Core Data: Using a temporary property for progress?

I’m currently creating an iOS app that uploads files to a server. As multiple uploads can be queued and have metadata attached that I want to store persistently, I’m using Core Data to model and store uploads. I’m also using NSFetchedResultsController to display all uploads in a table view. So far so good.

I’m now implementing a progress indicator and that’s where I’m unsure if my implementation is really a good idea. I’ve added a float property to my model which gets updated by my upload controller as the upload progresses. I’m then updating my UITableViewCell subclass with the help of NSFetchedResultsControllerDelegate and this works pretty well. However, it doesn’t really make sense to actually store this property persistently, since uploads can’t be resumed if the app gets terminated. I’m only using the property to connect my upload controller and view controller. Is there a better way to do this without losing the convenience of NSFetchedResultsController?

Upvotes: 0

Views: 639

Answers (1)

Warren Burton
Warren Burton

Reputation: 17382

If you marker your property as Transient in the model editor it means that it wont be stored in the persistent file.

The property will reset to default each time the MO loads, though im unsure of the rules around at what point they will reset if you are not retaining specific instances of the MO's

This guy, http://2pi.dk/tech/cocoa/transient_properties.html seems to know.

Upvotes: 2

Related Questions