Title: Theory / Important / CS / Programming / Objective-C / Style guide
On every note of this deck, unless a note says otherwise:
Page: https://google.github.io/styleguide/objcguide.html

Instruction: - (instancetype)initFoo... NS_DESIGNATED_INITIALIZER;
Page: https://google.github.io/styleguide/objcguide.html
Effect: Indicate that initFoo... is the designated initializer
Language: Objective-C

Question: Should you use import or include in Objective-C
Answer: Import for objective-C
Answer2: #include for c/c++ headers

Question: which type should return init
Answer: instancetype

Question: How should names be
Answer: descriptive as possible
Section: Naming
Context: Objective-C
Answer2: avoid non standard abbreviation

Question: How to capitalize acronyms
Answer: All capitals and initialism
Section: Naming
Context: Objective-C

Question: How to capitalize C functions
Answer: capitalized and use camel-case as appropriate for the surrounding code
Section: Naming
Context: Objective-C

Question: How to capitalize C typedef
Answer: capitalized and use camel-case as appropriate for the surrounding code
Section: Naming
Context: Objective-C

Question: Restriction on prefix for Objective-C library
Answer: 3 characters at least. 2 are reserved for Apple
Section: Naming
Context: Objective-C

Question: How to capitalize class name
Answer: Start as upper case and use mixed case to delimit words
Context: Objective-C

Question: How to capitalize category name
Answer: Start as upper case and use mixed case to delimit words
Context: Objective-C

Question: How to capitalize protocol name
Answer: Start as upper case and use mixed case to delimit words
Context: Objective-C

Question: How should be category file name
Answer: Class being extended followed by a plus sign and the name of the category. E.g. NSString+GTMParsing.h
Context: Objective-C

Question: How should be name of methods in category
Answer: lowercase version of the prefix used for the category name followed by an underscore. E.g. gtm_myCategoyMethodOnAString:
Context: Objective-C

Question: in class declaration, how to separate class name from parentesis
Answer: single space, no new line
@interface UIViewController (GTMCrashReporting)
Context: Objective-C

Question: How should method name be
Answer: Start with lowercase and use mixed case
Context: Objective-C

Question: How should method parameter name be
Answer: Start with lowercase and use mixed case
Context: Objective-C

Question: How to name a method that returns an object
Answer: name starts with the noun identifying the object returned
Context: Objective-C

Question: How to name an accessor
Answer: the name of the object accessed
Context: Objective-C

Question: How to name an accessor for boolean adjective
Answer: isAdjective
Context: Objective-C

Question: How to name a boolean property
Answer: usually an adjective
Context: Objective-C

Question: How to name objective C non-static function
Answer: With Prefix and upper-casing each word
Context: Objective-C

Question: How to name instance variables
Answer: leading underscore, upper case to separate each word except the first one
Context: Objective-C

Question: How to name file scope or global variable
Answer: `g` then normal variable name with upper case to separate each word
Context: Objective-C

Question: How to name local variable
Answer: start with lower case, then upper case on each new word
Context: Objective-C

Question: How to name constant
Answer: Mixed case to delimit word.
Context: Objective-C

Question: How to name constant of static storage duration declared within implementation file
Answer: `k` followed by a captial for each word
Context: Objective-C

Question: In which order should be declarations in an @interface
Answer: properties
Context: Objective-C
Answer2: class methods
Answer3: initializers
Answer4: convenience constructors
Answer5: other Instance methods

Question: Where should be declared local variables
Answer: In the narrowest scope
Context: Objective-C

Question: Should you initialize local variables
Answer: yes, even if sometime it's not necessary
Context: Objective-C

Question: When can you use unsigned integers
Answer: When matching NSUInteger in system interface
Context: Objective-C
Answer2: flags
Answer3: bitmask

Question: Which integral type to use by default
Answer: explicitly sized type
Context: Objective-C
Answer2: signed

Question: When to use types with non-explicit size (NSInteger, CGFloat)
Answer: when matching system interface
Context: Objective-C

Question: When to change author lines of a file
Answer: when making significant change
Context: Objective-C

Question: Should code file has author line
Answer: no
Context: Objective-C

Question: Which syntax should declaration comments use
Answer: doxygen
Context: Objective-C

Question: How to formulate declaration comment
Answer: Use descriptive form (“Opens the file”) rather than imperative form (“Open the file”)
Context: Objective-C

Question: What to document in a declaration
Answer: Any sentinel value
Context: Objective-C
Answer2: Any assumption e.g. about threading
Answer3: How the method/function is used, not how it's implemented

Question: How to indent end of line comment
Answer: At least two spaces
Context: Objective-C
Answer2: Align with nearby comments

Question: How to indicate symbols in comment
Answer: `, |, before them, or nothing if no ambiguity
Context: Objective-C
Answer2: @c if using DoxyGen

Question: Should you document object ownership
Answer: Only if not explicit, not using ARC, and no indication such as __weak
Context: Objective-C

Question: How to name macros
Answer: SHOUTY_SNAKE_CASE
Context: Objective-C

Question: When to use macros
Answer: Avoid as much as possible. Uses const, enums, snipped, c function instead
Context: Objective-C

Question: Constraint on macros
Answer: Balanced
Context: Objective-C
Answer2: Don't introduce scope
Answer3: Don't obscure capturing of values in blocks

Instruction: - (instancetype)initFoo... NS_UNAVAILABLE;
Page: https://google.github.io/styleguide/objcguide.html
Effect: Indicate that initFoo... can't be call on this class
Language: Objective-C

Question: how to create init for child class
Answer: override parent designated initializer or make it NS_UNAVAILABLE
Context: Objective-C

Question: In which order to put methods in @implementation
Answer: init
Context: Objective-C
Answer2: Convenience class factory methods for creating instances
Answer3: Overriden methods
Answer4: methods of this class

Question: Should you initialize instance variables
Answer: Only if not 0 and not nil
Context: Objective-C

Question: Can you use +new methods
Answer: No
Context: Objective-C

Question: What should be the accessibility of instance variables
Answer: @protected or @private
Context: Objective-C

Question: Constraint on name of private method
Answer: Very unique, to avoid overriding it while inheriting (they are not really private)
Context: Objective-C

Question: What's the order of group of inclusion
Answer: related header
Context: Objective-C
Answer2: OS headers
Answer3: Language library headers
Answer4: Grops of headers for other dependencies

Question: What's the order of inclusion in a group
Answer: Alphabetical
Context: Objective-C

Question: How to name files in #import
Answer: path relative to the project's source directory
Context: Objective-C

Question: Should you prefer detailled import or umbrella import
Answer: umbrella
Context: Objective-C

Name: An umbrella file
Definition: A file that only import many other files and make them accessible to files that import current file
Page: https://google.github.io/styleguide/objcguide.html
Context: Objective-C

Name: Constraint on initializer
Definition: Don't message the current object. Only use ivar direct access
Page: https://google.github.io/styleguide/objcguide.html
Context: Objective-C

Name: Constraint on -dealloc
Definition: Don't message the current object. Only use ivar direct access
Page: https://google.github.io/styleguide/objcguide.html
Context: Objective-C

Question: Constraint on NSArray/NSDictionnary setter
Answer: Usually copy the array/dictionnary unless justified not to do so
Context: Objective-C

Question: Constraint on NSString setter
Answer: Copy the string
Context: Objective-C

Question: Can you @throw
Answer: No, but you may have to catch it
Context: Objective-C

Question: What to do when using @try, @catch and @finally
Answer: Document what may throw and what is thrown
Context: Objective-C

Question: When to check for `nil`
Answer: Not for sending it a message.
Context: Objective-C

Instruction: type _Nonnull var
Page: https://google.github.io/styleguide/objcguide.html
Meaning: same as `type var`, noting that var can't be null
Context: Objective-C

Instruction: type _Nullable var
Page: https://google.github.io/styleguide/objcguide.html
Meaning: same as `type var`, noting that var can be null
Context: Objective-C

Question: How to convert ints to Bool
Answer: Use standard numerical comparison predicate to check what values are exactly expected
Context: Objective-C

Question: How to convert bool, BOOL and _Bool
Answer: They are interchangeable
Context: Objective-C

Question: What are the possible values of a BOOL
Answer: any int
Context: Objective-C

Question: What to do if an interface has no ivar
Answer: don't put its optional {}
Context: Objective-C

Question: When should a delegate should be released
Answer: As soon as it's clear there will no longer be a need to message it
Context: Objective-C
Answer2: If it may never occurs, keep it weakly

Question: When should a target pointer should be released
Answer: As soon as it's clear there will no longer be a need to message it
Context: Objective-C
Answer2: If it may never occurs, keep it weakly

Question: How to do callback
Answer: by block if it's clear the block is released after they have been called, or once they are no longer needed
Context: Objective-C
Answer2: use weak delegate or target pointers

Question: In objective-c++, which of C++ and Objective-C must be followed
Answer: Inside of class, the style of the language of the class defined.
Context: Objective-C++
Answer2: Outside of class, be consistent in the file

Question: How to indent
Answer: only use space.
Context: Objective-C++
Answer2: Two space by indentation
Answer3: four spaces at least to indent each argument of a method.

Question: How long should lines be
Answer: At most 100 columns
Context: Objective-C++

Question: How to format method declaration
Answer: + (returnType)methodNameWithArg1:(ArgType1)argName1 andArg2:(argType2)argName2 {
  ...
}
Context: Objective-C++

Question: When can block be omitted on if
Answer: When the entire comment fit on the same line as the conditional
Context: Objective-C++
Answer2: there is no else

Question: When can syntactic block be omitted after loop and replaced by expression
Answer: When the entire comment fit on the same line as the loop
Context: Objective-C++

Question: How to do fall-through
Answer: Document explicitly unless there is no instruction in the current case
Context: Objective-C++

Question: When can you omit spaces around operators
Answer: unary operators
Context: Objective-C++
Answer2: factors in expressions. E.g.
w*x + y/z

Question: How to format method invocation
Answer: Either on a single line
Context: Objective-C++
Answer2: or one argument by line. Aligned at colon

Question: How to format function call
Answer: Put as much argument per line as possible, unless doing otherwise clarify it
Context: Objective-C++

Question: How to catch excetpion
Answer: @try {
  foo();
} @catch (NSException *ex) {
  bar(ex);
} @finally {
  baz();
}
Context: Objective-C++

Question: What should be a function's body number of line
Answer: No limit. But over 40 lines, it must be thought about
Context: Objective-C++

Instruction: // NOLINT
foo
// NOLINTNEXTLINE
Page: https://google.github.io/styleguide/objcguide.html
Effect: Same as foo but accept to have incorrect formatting
Context: Objective-C++

Question: Should you put space after unary operator
Answer: no

Question: Should you put space around binary operator
Answer: usually yes, except for grouping on highest priority operation