ios - Core Data modeling issues (how to update attribute based on a relation's relation?) -


i have entity (order) has to-many relationship entity item, has to-many relationship entity note. if price changes note, or note added, 'price' attribute associated order must update.

right now, solution have order objects sign nsmanagedobjectcontextdidchange notifications, , check inserted/changed objects see if of objects 1 of order's item's notes. however, inefficient , hacky, , leading few more performance issues can optimized away, i'm starting realize solution what's faulty, not issues.

so, what's best way this?

edit: answer questions brought rog: i'm looking propagate changes model data, observed view controllers via kvo. problem i'm noticing is, if price of note related item adjusted, there's no facility account in core data. if use keypathsforaffectingprice on item, , return "notes", accounts if notes inserted/deleted, not if note price adjusted.

if wasn't core data, i'd write own accessor note price [self.item willchangevalueforkey:@"price"], self.price = x, [self.item didchangevalueforkey:@"price"]; isn't possible since can't custom accessors in core data, right?

we problably need more details code able - i.e. looking @ ways propagate changes model data or ui?

are using fetchedresultscontroller @ moment?

the way see it, if order contains items , items contain notes, updates "child" attributes effective (provided have reverse relationships setup properly).

then if you're looking @ ways updating ui accordingly, need know how fetching , populating views coredata entities.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -