IOS--静态多线程
2016-03-02 14:12
405 查看
TestController.m
#import "TestController.h" #import "TestView.h" @interface TestController() @property(nonatomic,strong)UIButton *button; @end @implementation TestController - (void)viewDidLoad { [super viewDidLoad]; _button = [UIButton buttonWithType:UIButtonTypeSystem]; _button.frame = CGRectMake(0, 20, 100, 20); [_button setTitle:@"Hello" forState:UIControlStateNormal]; [_button addTarget:self action:@selector(start:) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:_button]; } -(void)start:(UIButton*)sender { //静态多线程 [NSThread detachNewThreadSelector:@selector(thLoop) toTarget:self withObject:nil]; } -(void)thLoop { for (int i =1; i<=10 ; i++) { //睡眠1秒 [NSThread sleepForTimeInterval:1]; NSLog(@"i=%d",i); } NSLog(@"end"); } @end
相关文章推荐
- iOS开发通过代码方式使用AutoLayout (NSLayoutConstraint + Masonry)
- iOS开发技巧:获取手机应用程序图片素材
- IOS开发基础知识--碎片35
- iOS开发之封装水平菜单栏
- ios版本更新
- [iOS]细说OC中的load和initialize方法
- 获取iOS设备信息
- IOS 无法解析 报错std::basic_string/std::string::find
- iOS 中 set,get方法
- iOS 中单例写法
- iOS 成员变量跟属性的区别
- 【iOS】使用Xib自定义tableViewCell 获取数据
- iOS的本地消息推送。
- iOS url重定向
- iOS大转盘抽奖
- iOS 拨打电话功能
- iOS 教你如何实现手势密码
- iOS开发通信 ——— Socket之浅谈
- IOS 3D Touch 开发教程
- IOS-加载动态图(gif)