装箱与拆箱的概念

        //经过数字类型建立数字对象(装箱)spa

        NSNumber *num1 = [[NSNumber alloc] initWithInteger:123];3d

        NSLog(@"%@", num1);orm

        NSNumber *num2 = [[NSNumber alloc] initWithDouble:12.3];对象

        NSLog(@"%@", num2);it

        

        NSNumber *num3 = [NSNumber numberWithInt:34];margin

        NSLog(@"%@", num3);top

        

        NSArray *arr1 = [NSArray arrayWithObjects:@"one", num1, nil];ant

        NSLog(@"%@", arr1);co

        

        //数字对象转换为基本数字类型(拆箱)数字

        NSInteger value1 = [num1 integerValue];

        NSLog(@"value = %ld", value1);

相关文章
相关标签/搜索