有時(shí)候代碼中有一些和我們平時(shí)看到的不一樣,如下:
UILabel *l = [[UILabel alloc]initWithFrame:CGRectMake(0, 20, 100, 40)];
l.text = @"hello";
[self.view addSubview:l];
{
UILabel *l = [[UILabel alloc]initWithFrame:CGRectMake(0, 80, 100, 40)];
l.text = @"world";
[self.view addSubview:l];
}
//擴(kuò)展知識(shí)點(diǎn):要能看懂,在一些老的代碼中會(huì)有
//{}包裝代碼,()表示執(zhí)行
//工作中,看到的最多的表現(xiàn)是UITableView
UILabel *myLabel = ({
UILabel *l = [[UILabel alloc]initWithFrame:CGRectMake(0, 280, 100, 40)];
l.text = @"hello,world";
[self.view addSubview:l];
//最末尾的l會(huì)給myLabel設(shè)置數(shù)值
l;
});
NSLog(@"%@",myLabel);
我只能說(shuō)知道就好,沒(méi)有什么高端的。