IOS第二天多线程-02一次性代码

**********

#import "HMViewController.h"
#import "HMImageDownloader.h" @interface HMViewController ()
//@property (nonatomic, strong) HMImageDownloader *downloader;
@end @implementation HMViewController - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. // self.downloader = [[HMImageDownloader alloc] init];
} - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"----touchesBegan");
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ //只能执行一次
NSLog(@"----once");
HMImageDownloader *downloader = [[HMImageDownloader alloc] init];
[downloader download];
});
} @end
上一篇:VMware下利用ubuntu13.04建立嵌入式开发环境之四


下一篇:[转] 使用 MYSQLBINLOG 来恢复数据