Title: Theory / Important / CS / Programming / Objective-C / Documentation / Block
Tags: automatedNewLineAfterCommaSpace

Instruction: ^ returnType (
  argType_1 argName_1,
  ...,
  argType_n argName_n
) {
  foo
}
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Language: Objective-C
Returns: A block, which takes n arguments with type argType_i, and execute foo, returning a value of returnType

Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Syntactic sugar: ^ (argType_1 argName_1, ..., argType_n argName_n) {
  foo
}
Implementation: ^ implicitReturnType (argType_1 argName_1, ..., argType_n argName_n) {
  foo
}
Language: Objective-C

Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
Syntactic sugar: ^{
  foo
}
Implementation: ^ () {
  foo
}
Language: Objective-C

Instruction: __block init
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html
https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxGettingStarted.html
Language: Objective-C
Similar to: init
Scope: This value is shared with any block in the scope of this declaration

Question: Restriction on C++ stack-based object withing a block
Answer: It must have a const copy constructor
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html
Context: Objective-C

Instruction: Block_Copy(block)
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html
Language: Objective-C
Returns: A copy of block

Instruction: Block_release(block)
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxVariables.html
Language: Objective-C
Returns: Delete block
Assuming: block was created with a Block_copy

Instruction: Block_copy(block)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html
Language: Objective-C
Returns: A copy of block, stored on the heap

Instruction: Block_release(block)
Page: https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Glossary/Glossary.html
Effect: Free block
Language: Objective-C

Question: What should be avoided with blocks
Answer: Using them outside of the scope for which they were defined. E.g. don't assign them to variables that survives the scope where they are defined without copying them
Page: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Blocks/Articles/bxUsing.html
Context: Objective-C