我有一个类似于此处概述的问题: Has xcode 4.5 changed sortedArrayUsingComparator + blocks?
int index = [AAjouter indexOfObject:match inSortedRange:NSMakeRange(0, [AAjouter count]) options:NSBinarySearchingInsertionIndex usingComparator:^(id obj1, id obj2) {
Match *match1 = (Match *) obj1;
Match *match2 = (Match *) obj2;
if ([match1.matchDate isEqualToDate:match2.matchDate]) {
if ([match1.paysCompetition isEqualToString:match2.paysCompetition]) {
if ([[NSNumber numberWithInt:match1.ordreCompetition] isEqualToNumber:[NSNumber numberWithInt:match2.ordreCompetition]]) {
if ([match1.equipeANom isEqualToString:match2.equipeANom]) {
return NSOrderedSame;
}
else {
return [match1.equipeANom compare:match2.equipeANom];
}
}
else {
return [[NSNumber numberWithInt:match1.ordreCompetition] compare:[NSNumber numberWithInt:match2.ordreCompetition]];
}
}
else {
return [match1.paysCompetition compare:match2.paysCompetition];
}
}
else {
return [match1.matchDate compare:match2.matchDate];
}
}];
[AAjouter insertObject:match atIndex:index]; 休息;
我有这个错误信息:
“返回类型'NSComparaisonResult'(又名'NSComparaisonResult')必须匹配先前的返回类型'NSIntger'(又名'int')”
在每个代码行之后:
return [[NSNumber numberWithInt:match1.ordreCompetition] compare:[NSNumber numberWithInt:match2.ordreCompetition]];
return [match1.paysCompetition compare:match2.paysCompetition];
return [match1.matchDate compare:match2.matchDate];
你有什么想法吗?