したがって、ここには3つの異なるアレイが含まれています...
私はgolferThreeIcons(NSMutableArray)をループしていて、最高の4つの結果(golferThreeIconsには文字列として#が含まれています)を取得してtopFourIconsNum(NSMutableArray)に格納しようとしています。次に、その最高のIDを格納する予定です。配列topFourIconsId(NSMutableArray)の番号。
トリッキーなことの1つは、golferThreeIconsが99から始まることですが、それをゼロのように動作させたいと思います。したがって、99という数字はどちらの配列にも追加されるべきではありません...
例:golferThreeIcons {2,1,5,3,9}
そして、ループが通過した後、私はそれがこのようなものを表示したいです...
topFourIconsId {0,2,3,4}---0はゴルファーの2に対応ThreeIcons---2はゴルファーの5に対応3アイコン
topFourIconsNum {2,5,3,9} ----(上位4つのアイコンIDに対応する限り任意の順序)
NSMutableArray *topFourIconsId = [NSMutableArray arrayWithObjects: @"0", @"0", @"0", @"0", @"0" ,nil];
NSMutableArray *topFourIconsNum = [NSMutableArray arrayWithObjects: @"0", @"0", @"0", @"0", @"0" ,nil];
int *ids = 0;
for (NSString *s in golferThreeIconCounter) {
if(s != @"0") {
int sint = [s intValue];
int *idn = 0;
for(NSString *n in topFourIconsNum) {
int nint= [n intValue];
if(sint == 99 && nint == 0) {
NSString *idstring = [NSString stringWithFormat:@"%d", ids];
NSString *sintstring = [NSString stringWithFormat:@"%d", sint];
[topFourIconsId replaceObjectAtIndex:idn withObject:idstring];
[topFourIconsNum replaceObjectAtIndex:idn withObject:sintstring];
NSLog(@"IN %@",sintstring);
break;
}
else {
if (sint > nint) {
NSString *idstring = [NSString stringWithFormat:@"%d", ids];
NSString *sintstring = [NSString stringWithFormat:@"%d", sint];
[topFourIconsId replaceObjectAtIndex:idn withObject:idstring];
[topFourIconsNum replaceObjectAtIndex:idn withObject:sintstring];
NSLog(@"IN %@",sintstring);
break;
}
}
idn++;
}
}
ids++;
}