私に10人の子供(オブジェクト)がいて、各子供が異なる学校(配列)に行き、異なるシャツ(オブジェクトの値)がある場合。シャツの色に基づいて特定の子供を見つけるための最良の方法は何でしょうか?
今、私はこれを行いますが、これは少し長いようです:
Match *match;
match.match_id = @"The match id i want to find":
//Check array 1 for the object
for (Match *tempMatch in matchesGrouped)
{
if (tempMatch.match_id == match.match_id)
{
match = tempMatch;
matchFound = YES;
break;
}
}
//Check array 2 for the object
for (Match *tempMatch in matchesSingle)
{
if (tempMatch.match_id == match.match_id)
{
match = tempMatch;
matchFound = YES;
break;
}
}
etc for the rest of the arrays...
match_idは、一致ごとに一意の整数です。
前もって感謝します
編集:
試合は次のようになります。
@interface Match : UIViewController <NSCoding>
{
}
//Match
@property (nonatomic) int match_id;
@property (nonatomic) int matchStatus;
@property (nonatomic) int numberOfPlayers;
etc...