objective c - Correct way of dealing with Core Data NSManagedObjects in an iOS application -


when have worked java applications involving database , orm (object relationship manager) architecture separated when working database entities in database layer worked directly entities. if needed access entities in gui create data transfer object (dto) of entity , use in gui layer.

what preferred approach in ios applications?

one example fetch core data retrieve objects in viewcontroller , display results in tableview in viewcontroller. necessary convert nsmanagedobjects dtos before showing results?

what preferred approach in ios applications? necessary convert nsmanagedobjects dtos before showing results?

no, not neccessary. managed object (generic) object wrapping database entity. can access managed object's properties (ie entitys attributes) using -valueforkey: calls. preferred approach subclass nsmanagedobject fit entities. in xcode there option generate subclasses automatically (editor-> generate nsmanagedobject subclass). way own subclass object entities , can access properties using dot notation. on fetching objects, let result of type of subclass.

if want add custom methods entity objects, should create category on managed object subclass. because if change db scheme , have let xcode recreate subclasses, overwrites , custom methods lost.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -