Is it wrong to use an NSFetchedResultsController
purely for data management, i.e., without using it to feed a UITableView
?
I have a to-many relationship in a Core Data iPhone app. Whenever data in that relationship changes, I need to perform a calculation which requires that data to be sorted. In Apple's standard Department/Employees example, this would be like determining the median salary in a given Department. Whenever an Employee is added to or removed from that Department, or an Employee's salary changes, the median calculation would need to be performed again.
Keeping data sorted and current and getting notifications when it changes sounds like a great job for NSFetchedResultsController
. The only "problem" is that I'm not using a UITableView
. In other words, I'm not displaying sorted Employees in a UITableView
. I just want an up-to-date sorted array of Employees so I can analyze them behind the scenes. (And, of course, I don't want to write a bunch of code that duplicates much of NSFetchedResultsController
.)
Is it a bad idea to use an NSFetchedResultsController
purely for data management, i.e., without using it to feed a UITableView
? I haven't seen this done anywhere, and thought I might be missing something.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…