Reputation: 1443
When I update a transient attribute (and I guess other attributes) in an Entity with the following code
[passedObject setValue:distanceNumber forKey:@"distance"];
NSFetchedResultsController
deletes the object from the fetch results.
I guess I have to do [fetchedresultscontroller performFetch:&error]
to do a fetch again, but nothing happens, the object is not coming back to fetch results.
What I am missing? How can I update objects at runtime without been deleted from fetch of NSFetchResultController
?
Thanks
Upvotes: 1
Views: 462
Reputation: 1443
Thank you both for helping!
I was thinking that for transient attributes, you don't need to save the context. Wrong. That was the problem, I just needed to save the context.
Many thanks again.
Upvotes: 1
Reputation: 4329
BillKast,
Transient attributes are special and do not participate in fetch requests. You can think of them as always being nil on disk.
I would do a simpler experiment using just fetch requests instead of the fetched results controller.
Also, fork off a version of your app and change the type of the attribute to permanent. I suspect you'll see a different behavior.
As you don't list any code, I'm afraid I have no other suggestions. The transient attributes are your likely problem.
Andrew
Upvotes: 1
Reputation: 5960
What are the criteria for fetching? Do you use a predicate? Most likely, the change that you are making to the entity makes it not match the fetch predicate. When you make your change and then save it, this would cause the current fetched results controller to be notified by the managed object context that the context has changed. The fetched results controller then examines all changes and takes the appropriate action. It will remove objects that no longer match the original fetch criteria.
If you show the code for making the original fetch, someone can probably tell you exactly what the problem is.
Upvotes: 1