首页 > 代码库 > OC 类型转换

OC 类型转换

NSUInteger转换为NSNumber可以通过

NSNumber *aNumber = [NSNumber numberWithInteger:21];

来转换,然后把NSNumber放到数组里

最后要用数据的时候,把NSNumber从数组里取出来,然后通过

NSInteger anInteger = [aNumber integerValue];

拿到那个数字21


数组排序

    NSSortDescriptor *sd1 = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
    NSArray *arr1 = [selectArray sortedArrayUsingDescriptors:[NSArray arrayWithObjects:sd1, nil]];
    [selectArray  removeAllObjects];
    selectArray=[NSMutableArray  arrayWithArray:arr1];