NSArray
同じように並べ替えたいオブジェクトが 2 つあります。1 つはNSString
オブジェクトを含み、もう 1 つはカスタムAttribute
オブジェクトを含みます。これが私の「キー」NSArrayの外観です。
// The master order
NSArray *stringOrder = [NSArray arrayWithObjects:@"12", @"10", @"2", nil];
カスタム オブジェクトを含む NSArray:
// 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];
したがって、私がやりたいことは、配列を使用してカスタム オブジェクトstringOrder
の配列の並べ替えを決定することです。items
これどうやってするの?