ios - Swift: CoreData and generic NSOrderedSet -


i'm not sure if did not found information or if it's not possible.

i've looked several pages. want use generic generic version of nsorderedset in swift.

with set can this:

swift’s set type bridged foundation’s nsset class. source: apple docs - sets

in nsmanagedobject subclass can change nsset set , work. (tested it)

@property nsarray<nsdate *> *dates; @property nsset<nsstring *> *words; @property nsdictionary<nsurl *, nsdata *> *cacheddata;  var dates: [nsdate] var words: set<string> var cacheddata: [nsurl: nsdata] 

source: apple docs - lightweight generics

but couldn't find reference ordered set in swift. use nsorderedset objective-c won't have generics in swift then.

is there possibility define order in set in swift?

no, there no ordered set in swift , in honesty, shouldn't using ordered set period. of use.

but times, useful. don't have sort data yourself. when have entity list of sub entities won't sorted because set. , have create array have data prepared in specific order because plain set doesn't keep order. core data useful in use nsfetchedresultscontroller.

it lazy addition core data never should have happened. never more useful or more performant writing own sort routine. writing convenience method in subclasses produce ordered array faster , more performant using nsorderedset.

when using nsfetchedresultscontroller useless since nsfetchedresultscontroller orders you.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -