ios - Return unique/distinct values with Realm query -


i have message/rlmobject model has nsstring *jabberid property/row , want retrieve every unique value inside row.

in other word, want retrieve non-repeated jabberid values message model. can out figuring this?

the way use coredata using returnsdistinctresults setting on nsfetchrequest.

functional programming approach since swift has it, , realm lazy loads; not easy/available solution in objective-c swift @ least: swift

let distincttypes = reduce(realm().objects(user), []) { $0 + (!contains($0, $1.type) ? [$1.type] : [] ) } 

updated:

swift reduce kind of performance intensive, allocating bunch of intermediate array's, instead following should better performance wise, must explicitly cast

let distincttypes = array(set(realm().objects(user).valueforkey("type") as! [string])) 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -