- (void)viewDidLoad {
[super viewDidLoad];
dispatch_queue_t queue = dispatch_queue_create("myQueue", DISPATCH_QUEUE_CONCURRENT);
for (int i = 0; i < 10000; i++) {
dispatch_async(queue, ^{
self.str = [NSString stringWithFormat:@"asgdhjagsjhd"];
});
}
}我每次運行此代碼時爲什麼這個共存Objective-C代碼崩潰
,就會死機,誰能告訴我爲什麼?
你應該保持你的隊列在'viewDidLoad'之外。 – clemens