Sortuj NSArray obiektów niestandardowych na podstawie sortowania innego NSArray łańcuchów
mam dwaNSArray
obiekty, które chciałbym sortować tak samo. Jeden zawieraNSString
obiekty, inny zwyczajAttribute
przedmioty. Oto jak wygląda mój „kluczowy” NSArray:
// The master order
NSArray *stringOrder = [NSArray arrayWithObjects:@"12", @"10", @"2", nil];
NSArray z obiektami niestandardowymi:
// The array of custom Attribute objects that I want sorted by the stringOrder array
NSMutableArray *items = [[NSMutableArray alloc] init];
Attribute *attribute = nil;
attribute = [[Attribute alloc] init];
attribute.assetID = @"10";
[items addObject:attribute];
attribute = [[Attribute alloc] init];
attribute.assetID = @"12";
[items addObject:attribute];
attribute = [[Attribute alloc] init];
attribute.assetID = @"2";
[items addObject:attribute];
Więc chciałbym użyćstringOrder
tablica, aby określić sortowanieitems
tablica obiektów niestandardowych. Jak mogę to zrobić?