objective c - Sort a complex NSarray -
i have nsarray *userinputs
, array contains custom objects "userinput"
.
@interface userinput :nsobject { nsstring *page_id; @end
each userinput ( instance
of userinput
) belog bookpage
.
@interface bookpage: nsobject { nsstring *pageprefix; ( exemple : pageprefix = @"k1") @end
from each userinput
know witch bookpage
it's belong :
bookpage *bookpage = [self.book pagewithid:userinput.page_id];
how can sort array
of userinputs
( instances
of userinputs
) pageprefix
key. answers ?
you can sort array of custom object this:
nssortdescriptor *asortdescriptor = [[nssortdescriptor alloc] initwithkey:@"pageprefix" ascending:yes]; [userinputs sortusingdescriptors:[nsarray arraywithobject:asortdescriptor]];
Comments
Post a Comment