What prints to the console?
Task
Objective-C, the project is built without ARC (MRC), the code runs on the main thread:
NSObject *object = [NSObject new];
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"A %lu", (unsigned long)[object retainCount]);
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"B %lu", (unsigned long)[object retainCount]);
});
NSLog(@"C %lu", (unsigned long)[object retainCount]);
});
NSLog(@"D %lu", (unsigned long)[object retainCount]);
What prints, and in which order?
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep