Proper way to get possibly through Cocoa Bindings the last element of a relationship in Core Data -


i have managed-object x relationship list of [1:n) y objects. (x , y objects stored using core data)

i find proper (and more convenient) way obtain latest inserted y object. "name" attribute of y object should shown in graphic possibly through cocoa bindings.

i know ys inserted nsset, there no defined order. however, each y has "timestamp" attribute, when "the latest inserted y object" mean "the y latest timestamp".

any appreciated: searched documentation have not found me.

in kvc programming guide's collection operators section, description @max says

the @max operator compares values of property specified key path right of operator , returns maximum value found. maximum value determined using compare: method of objects @ specified key path. compared property objects must support comparison each other. if value of right side of key path nil, ignored.

the following example returns maximum value of date values (date of latest transaction) transaction objects in transactions:

nsdate *latestdate = [transactions valueforkeypath: "@max.date"]; 

the latestdate value (formatted) jul 15, 2010.


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) -