第一题
NSInteger age = 20;
void(^block)() = ^(){
NSLog(@"%li",age);//打印的值为几
};
age = 40;
block();
第二题
SCPerson *person = [[SCPerson alloc]init];
person.age = 20;
void(^block)() = ^(){
NSLog(@"%li",person.age);//打印的值为几
};
person.age = 40;
block();
第三题
SCPerson *person = [[SCPerson alloc]init];
person.age = 20;
void(^block)() = ^(){
NSLog(@"%li",person.age);//打印的值为几
};
person = [[SCPerson alloc]init];
person.age = 40;
block();
第四题
SCPerson *person = [[SCPerson alloc]init];
person.age = 20;
__weak SCPerson *weakPerson = person;
void(^block)() = ^(){
NSLog(@"%li",weakPerson.age);//打印的值为几
};
person = [[SCPerson alloc]init];
person.age = 40;
block();
第五题
SCPerson *person = [[SCPerson alloc]init];
person.age = 20;
__weak SCPerson *weakPerson = person;
void(^block)() = ^(){
__strong SCPerson *strongPerson = weakPerson;
NSLog(@"%li",strongPerson.age);//打印的值为几
};
person = [[SCPerson alloc]init];
person.age = 40;
block();