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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -