Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fix code snippet syntax

...

We attempt to follow the Google coding standards and Apple Cocoa guidelines. The remainder of this document reiterates information from these where appropriate, and otherwise provides exceptions to their standards.

We use "Modern Objective-C", the features of which are described in these documents.

Appcelerator C/C++ standards

...

  • Block variables should never be a raw type; they should always have a typedefassociated with them and that name used as the variable type.
    • EXCEPTION: The void (^varname)(void) block type does not require a typedef, although there are plenty of existing convenience typedefs for this block type which should be used when appropriate.
  • Blocks should have their opening brace on the same line as their ^, and their closing brace on its own line, indented with the surrounding scope.
  • Blocks have their contents indented one tabstop from the surrounding scope.
  • The void ^(void) block type should always be written as {{ ^{ ... } }}.
  • __block storage specifier objects should be used with care. Remember that if a __block variable goes out of scope when a block tries to access it, there can be unpredictable and bad results.

...

  • Do not mix nil and NULL. NULL should only be used for C-style pointers, and nil for all Objective-C object (and id) types.
  • It is illegal to use a statement such as {{ if (objcObject) { ... } }}. Instead directly compare to nil, only where required. Remember that it is actually faster to send a message to nil than to perform the cmp/jmp instructions from an if and make a method call. This is especially true on RISC architectures like ARM.

...