标签:
TestController.m
1 #import "TestController.h" 2 #import "TestView.h" 3 4 @interface TestController() 5 6 @property(nonatomic,strong)UIButton *button; 7 8 @end 9 10 @implementation TestController 11 12 - (void)viewDidLoad 13 { 14 [super viewDidLoad]; 15 16 _button = [UIButton buttonWithType:UIButtonTypeSystem]; 17 18 _button.frame = CGRectMake(0, 20, 100, 20); 19 [_button setTitle:@"Hello" forState:UIControlStateNormal]; 20 21 [_button addTarget:self action:@selector(start:) forControlEvents:UIControlEventTouchUpInside]; 22 23 [self.view addSubview:_button]; 24 25 } 26 27 28 -(void)start:(UIButton*)sender 29 { 30 //静态多线程 31 [NSThread detachNewThreadSelector:@selector(thLoop) toTarget:self withObject:nil]; 32 } 33 34 -(void)thLoop 35 { 36 for (int i =1; i<=10 ; i++) { 37 38 //睡眠1秒 39 [NSThread sleepForTimeInterval:1]; 40 NSLog(@"i=%d",i); 41 } 42 43 NSLog(@"end"); 44 45 } 46 47 48 @end
标签:
原文地址:http://www.cnblogs.com/yuge790615/p/5234779.html