How to make a hard link between coredata / NSManagedObject model data changes with application user interface?

TL DR - To simplify the whole description of how to implement a UI implementation that is independent of the type of table, when the properties of the underlying data object are often updated in the background. And with this, the visual representation of the data needs to be updated immediately. [In tableview, it is very easy to handle, you use FRC and just reload the line when the object is updated, through the FRC delegate methods.]


I know about NSFetchedResultsControllerand mapping it to the user interface. But this is only when the user interface is list-based.

In my case, several hardware of this type are connected to my application via bluetooth (BLE), and each usually provides updates with a frequency of 1 second in general. For example, temperature, charge changes.

So here is an example UI thread,

List โ†’ Details

More details

  • Health
  • Activity
  • Set up notifications

Details simply represent hardware-related data (serial number, firmware version, production date, etc.), and it has 3 buttons, named above, which when you click on the corresponding controllers.

Entity , , let say say ABC. ABC , HealthDetails, Activity, NotificationSetting HardwareDetails. ABC , identifier, connected, name ..

ListViewController UITableViewController, NSFetchedResultsController. - , Title, " ", " " , . , ..

NSFetchedResultsController.

[ / , , FRC, .]

. UI .

, my BluetoothManager , DatabaseHelper, , point , .

UIViewController , , . , , . .

, , , . , , ?


, FRC, , FRC , tableview. . - - / , .

, FRC , , FRC ? ?

+4
5

. NSFetchedResultsController , - . , . , FRC NSManagedObject , , , - .

, , , controllerDidChangeContent(_:)

, , .

+2

"ViewControllers", , , " > " " > " " > " ", UIViewController , ? , viewWillAppear . , , , , , (b/c ). viewDidLoad, , . viewWillAppear .

, , viewWillAppear , . , - , , (), , . , / .

, , . - .

, , , FRC . , FRC ( , , ).

, , - , . , .

+2

, , .

, FRC. /, CoreStore ObjectMonitor - , ( ) . , .

+2

, , . . , , VC, VC , . .

FRC , /, , . controllerDidChangeContent: . , , , ( , ).

VC , /, - /, FRC -, .

, , KVO, . , , / . KVO , , , .

KVO , .

+2

, - . ( : "--", . .)

"" - : . , ? NSManagedObjectContextDidSaveNotification, . .

?

+1

All Articles