iphone - is there a way to sort an array by category on ios -


how can create custom sort order on app? suppose have company , workers divided positions inside factory , wanna see performance of workers on specific position. could, on core data, predicate result wanna, @ same time, see more 1 positions, constructor, driver, engineer, etc. how can order fetch request result should of constructors first, drivers , @ end of of engineers?

thanks in advance , hope explained want.

just create nssortdescriptor position when fetch coredata.

nssortdescriptor *sortdescriptor = [nssortdescriptor sortdescriptorwithkey:@"position" ascending:yes]; [fetchrequest setsortdescriptors:@[sortdescriptor]]; 

that go positions alphabetically... if don't want done alphabetically implement new attribute nsnumber keep track of sort order want , fetch based upon that. this post seems talk bit example.

however, if order going different @ times, might better off holding nsmutablearray total list, , performing individual fetches each position, each time adding results end of same array...


Comments

Popular posts from this blog

How can we post XML strings along with text strings in iOS -

How to run C# code using mono without Xamarin in Android? -

c# - cefsharp app remember password option -