1.C的基本类型使用NSNumber(bool char double int float long)
NSNumber *ageNumber = [NSNumber 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;
};
*/
3.
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;
4.对结构体进行封装
NSValue *rectV = [NSValue valueWithRect:rect];
NSValue *pointV = [NSValue valueWithPoint:origin];
NSValue *sizeV = [NSValue valueWithSize:size];
CGRect rect1 = [rectV rectValue];