有時候代碼中有一些和我們平時看到的不一樣,如下:
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];
}
//擴展知識點:要能看懂,在一些老的代碼中會有
//{}包裝代碼,()表示執行
//工作中,看到的最多的表現是UITableView
UILabel *myLabel = ({
UILabel *l = [[UILabel alloc]initWithFrame:CGRectMake(0, 280, 100, 40)];
l.text = @"hello,world";
[self.view addSubview:l];
//最末尾的l會給myLabel設置數值
l;
});
NSLog(@"%@",myLabel);
我只能說知道就好,沒有什么高端的。