Fork me on GitHub

一些小知识点

https://cdn.pixabay.com/photo/2016/04/05/11/04/india-1309206__340.jpg

结构体

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
struct BMerson {
int age;
double height;
};

typedef struct BMerson BMerson;

BMerson BMersonMake1(int a, double h) {
BMerson p = {1, 1.0};
return p;
}

BMerson BMersonMake2(int a, double h) {
BMerson p = {
.age = a,
.height = h,
};
return p;
}

const关键字

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
int a1 = 0;
a1 = 10;

const int a2 = 0;
printf("%d", a2);
// error a2 = 10;

int const a3 = 0;
printf("%d", a3);
// error a3 = 10;
}

{
int a1;
int *p1;
p1 = &a1;
*p1 = 10;

const int *p2;
const int a2 = 10;
p2 = &a2;
p2 = &a1;
// error *p2 = 10;

int const *p3;
p3 = &a2;
p3 = &a1;
// error *p3 = 10;

int * const p4 = NULL;
// error p4 = &a2;
// error p4 = &a1;
*p4 = 10;

const int * const p5;
printf("%p", p5);
// error p5 = &a2;
// error p5 = &a1;
// error *p5 = 10;
}

iOS中的常量

常量

  • 通知名
1
2
3
4
UIKIT_EXTERN NSNotificationName const BMLoginSuccessNotification;
// NSNotificationName const BMLoginSuccessNotification = @"BMLoginSuccessNotification";
extern NSNotificationName const BMLoginFailureNotification;
// NSNotificationName const BMLoginFailureNotification = @"BMLoginFailureNotification";
  • NSString常量
1
2
3
4
UIKIT_EXTERN NSString *const BMUserName;
// NSString *const BMUserName = @"BMUserName";
extern NSString *const BMUserKey;
// NSString *const BMUserKey = @"BMUserKey";
  • 值常量
1
2
3
4
UIKIT_EXTERN const CGFloat BMNavHeight;
const CGFloat BMNavHeight = 10.0f;
extern const CGFloat BMNavWidth;
const CGFloat BMNavWidth = 10.0f;

Apple 尺寸

设备型号 屏幕尺寸 开发尺寸 像素尺寸 倍图
4/4S 3.5英寸 320*480 640*960 @2X
5/5S/5C/SE 4.0英寸 320*568 640*1136 @2X
6/6S/7/8 4.7英寸 375*667 750*1134 @2X
6P/6SP/7P/8P 5.5英寸 414*736 1242*2208 @3X
X 5.8英寸 375*812 1125*2436 @3X
iPad Mini 4 / iPad Air 2 / iPad Pro (9.7) 9.7英寸 768*1024 1536*2048 @2X
iPad Pro(12.9) / iPad Pro(12.9) (第二代) 12.9英寸 1024*1036 2048*2732 @2X
iPad Pro(10.5) 10.5英寸 1112*834 2224*1668 @2X
- END -
关注微信公众号,发现更多精彩

文章作者:梁大红

特别声明:若无特殊声明均为原创,转载请注明,侵权请联系

版权声明:署名-非商业性使用-禁止演绎 4.0 国际