Stephen Hsu
Stephen Hsu

Reputation: 5187

How to observe the number of objects in a table view?

I need to observe the number of objects in a table view and display it with a badge. I use Core Data and NSFetchedResultsController in the project. Should I use KVO or other mechanisms?

Upvotes: 1

Views: 131

Answers (1)

Guo Luchuan
Guo Luchuan

Reputation: 4731

YES, of course you can use KVO to observe the number of the objects.

But , if the models (assume the number of the objects change in this part) code is your coding or you can modify the models code. I think you should better use NSNotifaction or delegate or block , it is just a callback when you change the objects count.

KVO is better to observer the var which in the standard library or in the class which you cannot modify

Upvotes: 1

Related Questions