- (void)viewDidLoad {
[super viewDidLoad];
self.lb=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 55,55)];
self.lb.backgroundColor=[UIColor redColor];
self.lb.text=@"0";
[self.view addSubview:self.lb];
[NSTimer scheduledTimerWithTimeInterval:1 target:selfselector:@selector(moo) userInfo:nil repeats:YES];
}
-(void)moo{
Mouse *mm=[[Mousealloc]initWithFrame:CGRectMake(arc4random()%333,arc4random()%666, 33, 33)];
// 委托模式,实例一个对象,在Mose里又一个属性 ViewController *vc,叫对象mm点出他的属性,之后把自身的页面给mm里的属性vc。
mm.vc=self;
[self.view addSubview:mm];
}
// 声明方法,叫Mouse类每次调用此方法是label的text数值加一
-(void)addS{
int old=self.lb.text.intValue;
int new=old+1;
self.lb.text=@(new).stringValue;
}