1、C语言基本类型使用NSNumber(bool char double int float)
NSNumber *ageNumber = [NSNmber numberWithInt:23];
NSnumber *ageNumber2 = @23;
int age = [ageNumber intValue];
2、C的复合类型结构NSValue
表示一个点(x, y)
struct CGPoint {
CGFloat x;
CGFloat y;
};
宽度和高度(width, height)
struct CGSize {
CGFloat width;
CGFloat height;
};
一个视图在界面上的尺寸(矩形区域)
struct CGRect {
CGPoint origin;
CGSize size;
};
*/
//1.如何创建一个CGPoint
CGPoint origin = CGPointMake(10, 10);
//2. 创建一个CGSize
CGSize size = CGSizeMake(200, 300);
//3. 创建一个CGRect
CGRect rect = CGRectMake(10, 10, 200, 300);
CGFloat x = rect.origin.x;
CGFloat y = rect.origin.y;
CGFloat width = rect.size.width;
CGFloat height = rect.size.height;
//对结构体进行封装
NSValue *rectV = [NSValue valueWithRect:rect];
NSValue *pointV = [NSValue valueWithPoint:origin];
NSValue *sizeV = [NSValue valueWithSize:size];
CGRect rect1 = [rectV rectValue];
NSLog(@"%@", rectV);