나는 몇 시간 동안이 문제를 해결하지 못했습니다. 핵심 데이터 모델에서 게임이 끝날 때 저장하는 배열의 배열이 있습니다. 내가 핵심 데이터에서 점수를로드하고이 항상 마지막 점수를 배치 점수 배열 내 10 개 높은 점수정렬 코어 데이터 NSMutableArray 이상한 결과
[self.scoresArray sortUsingFunction:firstNumSort context:@selector(totalScore)];
//function to sort high scores in the array
NSInteger firstNumSort(id str1, id str2, void *context) {
static int counter = 0;
NSLog(@"counter = %d", counter);
counter++;
//NSLog(@"should be sorting");
int num1 = [str1 totalScore];
int num2 = [str2 totalScore];
if (num1 > num2) {
NSLog(@"%@ is greater than %@", num1, num2);
return NSOrderedAscending;
}
else if (num1 < num2){
NSLog(@"%@ is less than %@", num1, num2);
return NSOrderedDescending;
}
else {
NSLog(@"%@ is the same as %@", num1, num2);
return NSOrderedSame;
}
}
와 함께있는 NSMutableArray 인 다음 함수를 사용하여 배열을 정렬의 ViewController 높은 점수로 돌아갈 때 저장 한 후 해당 값에 관계없이 목록 맨 위에 항목 ?? 낯선 것은 내가 내 애플 리케이션을 다시 시작할 때 같은 기능은 내가 원하는 바대로 내림차순으로 올바른 점수를 둡니다.하지만 사용자가 정확한 순서로 표시된 점수를보기 위해 앱을 다시 시작하지 못하게하려는 것입니다. 아무도 무슨 일이 일어나고 있는지에 대해 약간의 빛을 비춰 줄 수 있니?
많은 감사
쥘
str1과 str2는 어떤 유형입니까? – Eiko