2

In my iPhone app, I have an NSFetchedResultsController showing User objects in a UITableView. The User Objects have 0-many Log objects. A summary of the Log objects are shown together with their User object in the UITableView.

My app uses a tab bar, so user input in the logging tab require that the user tab's NSFetchedResultsController is triggered to reload.

So far I do it by writing to the User object:

log.user = nil;
log.user = [User current]; // Same as before. Just triggering a reload.
NSError *error = nil;
[myManagedObjectContext save:&error];

This works fine, but seems a bit like a hack.

Is there a better way to do this? Like specifying that changes in the Log object should propagate to the User object too?

4

1 回答 1

2
[myFetchedResultsController performFetch:&error];

但是你为什么要这样做呢?它应该只在有新数据要获取时重新加载。如果有新数据,则保存NSManagedObjectContext是正确的操作。

你的基本目标是什么?

于 2010-08-10T14:56:53.930 回答