私は2つのNSArray
のオブジェクトを並べ替えたいと思います。 1つはNSString
オブジェクト、もう1つはカスタムAttribute
オブジェクトです。カスタムオブジェクトと文字列の別のNSArrayのソートに基づいてカスタムオブジェクトのNSArrayを並べ替えます。
// The master order
NSArray *stringOrder = [NSArray arrayWithObjects:@"12", @"10", @"2", nil];
にNSArray:ここに私は、「キー」は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
カスタムオブジェクトの配列。 どうすればいいですか?
これは、配列を使用するためには良い場所のように見えるしていません。辞書や順序付けされた辞書がより適切で簡単になるかもしれません。 – Alexander