NSDictionary *glossary = [ NSDictionary dictionaryWithObjectsAndKeys ://不可变词典 以及 快速枚举词典的方式 词典是无序的
@"A class" ,
@"Abc" ,
@"B class" ,
@"Bcd" ,
@"C class" ,
@"Cde" , nil ];
for ( NSString *key in glossary) {
NSLog(@"%@%@",key,[glossary objectForKey:key]);
//数组排序
int i;
propNum = [NSMutableArray arrayWithCapacity:4];
for (i = 0; i <= 4; i++) {
[propNum addObject:[NSNumber numberWithInteger:[selfRandomNumber: 4to: 24]]];
}
NSLog(@"New`````````");
NSLog(@"排序前%@ %i",propNum,propNum.count);
for (int j = 0; j <=[propNumcount]-1 ; j++){ //多一次for循环变成为由大到小的排序,如果取消本循环则成为最小数在末尾
for (int j = 0; j <=[propNumcount]-1 ; j++) {
int x = (j == propNum.count - 1) ? propNum.count - 1 : j + 1;
NSInteger a1 = [[propNumobjectAtIndex:j] intValue];
NSInteger a2 = [[propNumobjectAtIndex:x] intValue];
if (a1 < a2)
[propNum exchangeObjectAtIndex:j withObjectAtIndex: x];
}
}
NSLog(@"排序后%@",propNum);
[propNum removeLastObject];
returnpropNum;