有时候代码中有一些和我们平时看到的不一样,如下:
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);
我只能说知道就好,没有什么高端的。
网友评论