#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self performSelectorInBackground:@selector(longOperation) withObject:nil];
}
/**
1. 如果使用 @"" 创建的字符串,内容如果是相同的,他的地址也是相同
2. 它存在常量区 / 静态
3. 创建cell重用id的时候,其实可以不用写 static
*/
- (void)longOperation {
/**
主需要看number ,名字可以自己起
number == 1 的时候,是主线程
number != 1 的时候,就是后台线程
*/
NSLog(@"%@",[NSThread currentThread]);
int count = 1000 * 10;
NSLog(@"start");
for (int i = 0; i < count; ++i) {
NSString *str = [NSString stringWithFormat:@"hello world %d",i];
NSLog(@"%@",str);
}
NSLog(@"end");
}
@end