一次性代码

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"----touchesBegan");
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{

       // NSLog(@"----once"); 只会打印一次
        NSLog(@"----once");
    });
}

 

posted @ 2016-04-07 21:59  nxz_diy  阅读(752)  评论(0)    收藏  举报