2012-05-05 14 views
0

intを含むNSStringを含むNSMUtableArrayをソートする際に問題があります。 私は次のように並べ替えています。この文字列forrmatに数値を含むNSMutableArrayを並べ替えます。

scoreString=[NSString stringWithFormat:@"%lld",GameScore]; 
    [scorearr addObject:scoreString]; 
    NSSortDescriptor* sortOrder = [NSSortDescriptor sortDescriptorWithKey: @"self" ascending: NO]; 
    NSArray *scoreArray= [scorearr sortedArrayUsingDescriptors: [NSArray arrayWithObject: sortOrder]]; 
    scorearr =(NSMutableArray *)ary; 
+0

ソートされていませんか? – vishiphone

答えて

0

私はそれが良いですので

NSNumber *inrank=[NSNumber numberWithInt:GameScore]; 
    scoreString=[NSString stringWithFormat:@"%lld",GameScore]; 
    [scorearr addObject:inrank]; 
    NSLog(@"%@",scorearr.description); 
    //sorting array 
    sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; 
    NSSortDescriptor* sortOrder = [NSSortDescriptor sortDescriptorWithKey: @"self" ascending: NO]; 
    NSArray *scoreArray= [scorearr sortedArrayUsingDescriptors: [NSArray arrayWithObject: sortOrder]]; 
    scorearr =(NSMutableArray *)scoreArray; 
    NSLog(@"%@",scoreArray.description); 
1

あなたはあなたがしていることの道を

NSSortDescriptor* sortOrder = [NSSortDescriptor sortDescriptorWithKey: @"self" ascending: NO]; 
[scorearr sortUsingDescriptors:[NSArray arrayWithObject: sortOrder]]; 

を書くために可変配列を使用している、これで完了しています[OK]を並べ替えるときに新しい配列を作成しません。

関連する問題