<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="styleguide.xsl"?>
<!--<GUIDE title="Google Objective-C Style Guide">-->
<GUIDE title="Google Objective-Cスタイルガイド 日本語訳">
<!-- r67 -->
<div align="center">
これは<a href="http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml">Google Objective-C Style Guide (2.24)</a>の日本語訳です。<br/>オリジナルと同様、<a href="http://creativecommons.org/licenses/by/3.0/">CC-By 3.0 License</a>で配布します。<br/>最終更新: 2011-05-08
</div>

<p align="right">

Revision 2.24
</p>



<div align="right">
  <address>
    Mike Pinkerton<br/>
    Greg Miller <br/>
    Dave MacLachlan <br/>
    （日本語訳 <a href="http://www.textdrop.net/">Takashi Sasai</a>）
  </address>
</div>
  
<OVERVIEW>

<!--
<CATEGORY title="Important Note">
-->
<CATEGORY title="重要な注意">
<!--
  <STYLEPOINT title="Displaying Hidden Details in this Guide">
-->
  <STYLEPOINT title="詳細情報の表示">
     <SUMMARY>
<!--
       This style guide contains many details that are initially
       hidden from view.  They are marked by the triangle icon, which you
       see here on your left.  Click it now.
       You should see "Hooray" appear below.
-->
       このスタイルガイドには詳細情報がたくさん盛り込まれていますが、最初のうちは表示されていません。左端にある矢印ボタンをクリックしてみてください。
       「やったね」と表示されるはずです。
     </SUMMARY>
     <BODY>
       <p>
<!--
        Hooray!  Now you know you can expand points to get more
        details.  Alternatively, there's an "expand all" at the
        top of this document.
-->
        やったね！ このように矢印ボタンをクリックすると詳細情報が表示されます。
        このドキュメントの先頭にある大きな矢印ボタンをクリックしても構いません。すると、すべての詳細情報が表示されます。
       </p>
     </BODY>
  </STYLEPOINT>
</CATEGORY>

<!--<CATEGORY title="Background">-->
<CATEGORY title="背景">

  <p>
<!--
    Objective-C is a very dynamic, object-oriented extension of C.  It's
    designed to be easy to use and read, while enabling sophisticated
    object-oriented design. It is the primary development language for new
    applications on Mac OS X and the iPhone.
-->
    Objective-Cとは、C言語に対して非常に動的なオブジェクト指向拡張を追加したプログラミング言語です。この言語は使いやすくて読みやすいように設計されており、複雑なオブジェクト指向設計がこなせます。またObjective-Cは、Mac OS XおよびiPhone上で動く新しいアプリケーションを開発するための主要な開発言語となっています。
  </p>
    
  <p>
<!--
    Cocoa is one of the main application frameworks on Mac OS X. It is a
    collection of Objective-C classes that provide for rapid development of
    full-featured Mac OS X applications.
-->
    Cocoaとは、Mac OS Xにおける主要なアプリケーションフレームワークのひとつです。これはObjective-Cクラスの集合により構成されています。Cocoaを使うことで、機能に富んだMac OS Xアプリケーションをすばやく開発できます。
  </p>

  <p>
<!--
    Apple has already written a very good, and widely accepted, coding guide
    for Objective-C. Google has also written a similar guide for C++. This
    Objective-C guide aims to be a very natural combination of Apple's and
    Google's general recommendations. So, before reading this guide, please make
    sure you've read:
-->
    AppleはすでにObjective-Cコーディングガイドを公開しています。これは非常によくできていて、開発者に広く受け入れられています。Googleもまた、C++コーディングガイドを公開しています。このObjective-Cガイドが目標にしているのは、AppleとGoogleが一般的に推奨していることを、できる限りそのまま組み合わせることにあります。そのため、このガイドを読む前に、以下のドキュメントを読んでおくことが望ましいです。
    <ul>
      <li>
        <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/index.html">
<!--
          Apple's Cocoa Coding Guidelines
-->
          AppleのCocoaコーディングガイドライン
        </a>
      </li>
      <li>
        
        <div>
          <a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">
<!--
            Google's Open Source C++ Style Guide
-->
            GoogleのオープンソースC++スタイルガイド
          </a>
        </div>
      </li>
    </ul>
  </p>

  

  <p>
<!--
    <em>Note that all things that are banned in Google's C++ guide are also
    banned in Objective-C++, unless explicitly noted in this document.</em>
-->
    たとえ本ドキュメントに明記されていなくても、GoogleのC++スタイルガイドで禁止されていることは、Objective-C++でもすべて禁止されていることに注意してください。
  </p>

  <p>
<!--
    The purpose of this document is to describe the Objective-C (and
    Objective-C++) coding guidelines and practices that should be used for all
    Mac OS X code. Many of these guidelines have evolved and been proven over
    time on other projects and teams.
    
    Open-source projects developed by Google
    conform to the requirements in this guide.
-->
    本ドキュメントの目的は、あらゆるMac OS Xコードで使われるべき、Objective-C（およびObjective-C++）のコーディングガイドラインとプラクティスについて説明することです。このガイドラインの大部分は、さまざまなプロジェクトやさまざまなチームで何年もかけて作り上げられたもので、有効性が実証されています。

    Googleが開発しているオープンソースプロジェクトは、このスタイルガイドに準拠しています。
  </p>
  <p>
<!--
    Google has already released open-source code that conforms to these
    guidelines as part of the 
    <a href="http://code.google.com/p/google-toolbox-for-mac/">
      Google Toolbox for Mac project
    </a>
    (abbreviated GTM throughout this document).
    Code meant to be shared across different projects is a good candidate to
    be included in this repository.
-->
    Googleはすでに、
    <a href="http://code.google.com/p/google-toolbox-for-mac/">
      Google Toolbox for Mac project
    </a>
    （本ドキュメントでは省略して、GTMと呼びます）の一部として、このガイドラインに準拠したオープンソースコードをリリースしています。他のプロジェクトと共有する予定のあるコードは、このリポジトリに入れておくとよいでしょう。
  </p>
  
  

  <p>
<!--
    Note that this guide is not an Objective-C tutorial. We assume that the
    reader is familiar with the language. If you are new to Objective-C or
    need a refresher, please read 
    <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/index.html">
      The Objective-C Programming Language
    </a>.
-->
    このガイドはObjective-Cのチュートリアルではないことに注意してください。読者はあらかじめObjective-Cについてよく知っていることを想定しています。Objective-Cを使うのが初めての人や、もう少し勉強する必要があると感じている人は、まず
    <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/index.html">
      The Objective-C Programming Language
    </a>
    を読んでください。
  </p>
</CATEGORY>
</OVERVIEW>

<!--
<CATEGORY title="Example">
-->
<CATEGORY title="例">

  <p>
<!--
    They say an example is worth a thousand words so let's start off with an
    example that should give you a feel for the style, spacing, naming, etc.
-->
    百聞は一見にしかず、ということわざがあります。まずは例を見てみましょう。スタイル、空白、命名規則などが実際にどんな感じか、雰囲気がつかめるはずです。
  </p>

  <p>
<!--
    An example header file, demonstrating the correct commenting and spacing
    for an <code>@interface</code> declaration
-->
    ヘッダファイルの一例。<code>@interface</code> 宣言のためのコメントと空白がどんな感じかわかるでしょう。
  </p>

<CODE_SNIPPET>
    //  GTMFoo.h
    //  FooProject
    //
    //  Created by Greg Miller on 6/13/08.
    //  Copyright 2008 Google, Inc. All rights reserved.
    //
    
    #import &lt;Foundation/Foundation.h&gt;
    
    // A sample class demonstrating good Objective-C style. All interfaces,
    // categories, and protocols (read: all top-level declarations in a header)
    // MUST be commented. Comments must also be adjacent to the object they're
    // documenting.
    //
    // (no blank line between this comment and the interface)
    @interface GTMFoo : NSObject {
     @private
      NSString *foo_;
      NSString *bar_;
    }
    
    // Returns an autoreleased instance of GMFoo. See -initWithString: for details
    // about the argument.
    + (id)fooWithString:(NSString *)string;
    
    // Designated initializer. |string| will be copied and assigned to |foo_|.
    - (id)initWithString:(NSString *)string;
    
    // Gets and sets the string for |foo_|.
    - (NSString *)foo;
    - (void)setFoo:(NSString *)newFoo;
    
    // Does some work on |blah| and returns YES if the work was completed
    // successfuly, and NO otherwise.
    - (BOOL)doWorkWithString:(NSString *)blah;
    
    @end
  </CODE_SNIPPET>
  
  <p>
<!--
    An example source file, demonstrating the correct commenting and spacing
    for the <code>@implementation</code> of an interface. It also includes the
    reference implementations for important methods like getters and setters,
    <code>init</code>, and <code>dealloc</code>.
-->
    ソースファイルの一例。インタフェースの <code>@implementation</code> のためのコメントと空白がどんな感じかわかるでしょう。このファイルには、ゲッタやセッタ、<code>init</code> や <code>dealloc</code> といった主要なメソッドのリファレンス実装も含まれています。
  </p>
  
  <CODE_SNIPPET>
    //
    //  GTMFoo.m
    //  FooProject
    //
    //  Created by Greg Miller on 6/13/08.
    //  Copyright 2008 Google, Inc. All rights reserved.
    //
    
    #import "GTMFoo.h"
    
    
    @implementation GTMFoo
    
    + (id)fooWithString:(NSString *)string {
      return [[[self alloc] initWithString:string] autorelease];
    }
    
    // Must always override super's designated initializer.
    - (id)init {
      return [self initWithString:nil];
    }
    
    - (id)initWithString:(NSString *)string {
      if ((self = [super init])) {
        foo_ = [string copy];
        bar_ = [[NSString alloc] initWithFormat:@"hi %d", 3];
      }
      return self;   
    }
    
    - (void)dealloc {
      [foo_ release];
      [bar_ release];
      [super dealloc];
    }
    
    - (NSString *)foo {
      return foo_;
    }
    
    - (void)setFoo:(NSString *)newFoo {
      [foo_ autorelease];
      foo_ = [newFoo copy];   
    }
    
    - (BOOL)doWorkWithString:(NSString *)blah {
      // ...
      return NO;
    }
    
    @end
  </CODE_SNIPPET>

  <p>
<!--
    Blank lines before and after <code>@interface</code>,
    <code>@implementation</code>, and <code>@end</code> are optional. If your
    <code>@interface</code> declares instance variables, as most do, any blank
    line should come after the closing brace (<code>}</code>).
-->
    <code>@interface</code>、<code>@implementation</code>、<code>@end</code> の前後の空行は、あってもなくても構いません。もし <code>@interface</code> がインスタンス変数を宣言しているなら、たいていの場合、閉じ中括弧（<code>}</code>）の後に空行を入れるべきです。
  <p>
  </p>
<!--
    Unless an interface or implementation is very short, such as when declaring
    a handful of private methods or a bridge class, adding blank lines usually
    helps readability.
-->
    わずかなプライベートメソッドやブリッジクラスを宣言するときなど、インタフェースや実装がごく短い場合を除いて、通常は空行を入れるようにしましょう。読みやすくなります。
  </p>

</CATEGORY>

<!--
<CATEGORY title="Spacing And Formatting">
-->
<CATEGORY title="空白と書式">

<!--
  <STYLEPOINT title="Spaces vs. Tabs">
-->
  <STYLEPOINT title="スペース対タブ">
    <SUMMARY>
<!--
      Use only spaces, and indent 2 spaces at a time.
-->
      スペースだけを使いましょう。インデントはスペース2つにします。
    </SUMMARY>
    <BODY>
      <p>
<!--
        We use spaces for indentation. Do not use tabs in your code.
        You should set your editor to emit spaces when you hit the tab
        key.
-->
        インデントにはスペースを使います。コードにタブを使ってはいけません。
        タブキーを押したときにはスペースが入力されるよう、エディタを設定しておくべきです。
      </p>
    </BODY>
  </STYLEPOINT>

<!--
  <STYLEPOINT title="Line Length">
-->
  <STYLEPOINT title="行の長さ">
    <SUMMARY>
<!--
      Each line of text in your code should be at most 80 characters long.
-->
      コードにおけるテキスト1行の長さは、長くても80文字にするべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Even though Objective-C tends to be a more verbose language than C++,
        to aid in the interoperability with that guide, we have decided
        to keep the limit at 80 columns as well. It's easier to live with
        than you might expect.
-->
        Objective-CはC++と比べて言葉が長くなりがちな言語ですが、C++のスタイルガイドと相互運用できるよう、C++と同じ80カラムに制限することにしました。これを受け入れるのは意外にも簡単です。
      </p>
      
      <p>
<!--
        We recognize that this rule is controversial, but so much existing
        code already adheres to it, and we feel that consistency is
        important.
-->
        このルールには賛否両論あると思いますが、既存のコードの大部分がすでにこれを守っています。そして、私たちは一貫性が重要だと考えています。
      </p>
      <p>
<!--
        You can make violations easier to spot in Xcode by going to <i>Xcode
        &gt; Preferences &gt; Text Editing &gt; Show page guide</i>.
-->
        Xcode の場合、<i>Xcode &gt; 環境設定 &gt; テキスト編集 &gt; ページガイドを表示</i> を設定しておけば、ルールに違反している箇所を簡単に見つけられます。
      </p>
    </BODY>
  </STYLEPOINT>

<!--
  <STYLEPOINT title="Method Declarations and Definitions">
-->
  <STYLEPOINT title="メソッドの宣言と定義">
    <SUMMARY>
<!--
      One space should be used between the <code>-</code> or <code>+</code>
      and the return type, and no spacing in the parameter list except between
      parameters.
-->
      <code>-</code> や <code>+</code> と戻り値との間には、スペースを1つ入れるべきです。パラメータリストには、パラメータ間のスペースを除いて、スペースを入れるべきではありません。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Methods should look like this:
-->
        メソッドは次のようにするべきです。
      </p>
      <CODE_SNIPPET>
        - (void)doSomethingWithString:(NSString *)theString {
          ...
        }
      </CODE_SNIPPET>
      <p>
<!--
        The spacing before the asterisk is optional. When adding new code,
        be consistent with the surrounding file's style.
-->
        アスタリスク（*）の前には、スペースを入れても入れなくても構いません。新しいコードを追加するときには、まわりにあるファイルのスタイルに合わせてください。
      </p>
      <p>
<!--
        If you have too many parameters to fit on one line, giving each its
        own line is preferred. If multiple lines are used, align each using 
        the colon before the parameter.
-->
        パラメータが多すぎて1行に収まりきらないときには、1行につきパラメータを1つ書いてください。パラメータが複数行にわたるときには、パラメータの前にあるコロンで整列させましょう。
      </p>
      <CODE_SNIPPET>
        - (void)doSomethingWith:(GTMFoo *)theFoo
                           rect:(NSRect)theRect
                       interval:(float)theInterval {
          ...
        }
      </CODE_SNIPPET>
      <p>
<!--
        When the first keyword is shorter than the others, indent the later
        lines by at least four spaces. You can do this by making keywords
        line up vertically, not aligning colons:
-->
        最初のキーワードが他のキーワードよりも短いときには、以降の行を少なくともスペース4つでインデントしてください。コロンで整列させるのではなく、キーワードの先頭で整列させても構いません。
      </p>
      <CODE_SNIPPET>
        - (void)short:(GTMFoo *)theFoo
            longKeyword:(NSRect)theRect
            evenLongerKeyword:(float)theInterval {
          ...
        }
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Method Invocations"> -->
  <STYLEPOINT title="メソッド呼び出し">
    <SUMMARY>
<!--
      Method invocations should be formatted much like method declarations.
      When there's a choice of formatting styles, follow the convention
      already used in a given source file.
-->
      メソッド呼び出しはメソッド宣言と同じ書式にするべきです。
      書式を選ぶときには、そのソースですでに使われている規約にしたがいましょう。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Invocations should have all arguments on one line:
-->
        呼び出しでは、次のようにすべての引数を1行に入れるか、
      </p>
      <CODE_SNIPPET>
        [myObject doFooWith:arg1 name:arg2 error:arg3];
      </CODE_SNIPPET>
      <p>
<!--
        or have one argument per line, with colons aligned:
-->
        次のように1行につき引数を1つ書いて、コロンで整列させるべきです。
      </p>
      <CODE_SNIPPET>
        [myObject doFooWith:arg1
                       name:arg2
                      error:arg3];
      </CODE_SNIPPET>
      <p>
<!--
        Don't use any of these styles:
-->
        次のような書式にしてはいけません。
      </p>
      <BAD_CODE_SNIPPET>
        [myObject doFooWith:arg1 name:arg2  // 引数を複数含む行がある
                      error:arg3];

        [myObject doFooWith:arg1
                       name:arg2 error:arg3];

        [myObject doFooWith:arg1
                  name:arg2  // コロンではなくキーワードで整列させている
                  error:arg3];
      </BAD_CODE_SNIPPET>

      <p>
<!--
        As with declarations and definitions, when the keyword lengths make
        it impossible to align colons and still have four leading
        spaces, indent later lines by four spaces and align keywords after the
        first one, instead of aligning the colons.
-->
        メソッド宣言やメソッド定義と同様に、キーワードが長いために、コロンで整列させると、先頭にスペース4つ分を空けられない場合があります。そのときには、コロンで整列させる代わりに、以降の行をスペース4つでインデントしてキーワードで整列させてください。
      </p>
      <CODE_SNIPPET>
        [myObj short:arg1
            longKeyword:arg2
            evenLongerKeyword:arg3];
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  
  <STYLEPOINT title="@public and @private">
-->
  <STYLEPOINT title="@publicと@private">
    <SUMMARY>
<!--
      The <code>@public</code> and <code>@private</code> access modifiers
      should be indented by 1 space.
-->
      <code>@public</code> および <code>@private</code> アクセス修飾子は、スペース1つでインデントするべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        This is similar to <code>public</code>, <code>private</code>, and
        <code>protected</code> in C++.
-->
        これはC++における <code>public</code>、<code>private</code>、<code>protected</code> のルールと同じです。
      </p>
      <CODE_SNIPPET>
        @interface MyClass : NSObject {
         @public
          ...
         @private
          ...
        }
        @end
      </CODE_SNIPPET>      
    </BODY>
  </STYLEPOINT>

<!--
  <STYLEPOINT title="Exceptions">
-->
  <STYLEPOINT title="例外">
    <SUMMARY>
<!--
      Format exceptions with each <code>@</code> label on its own line and a
      space between the <code>@</code> label and the opening brace
      (<code>{</code>), as well as between the <code>@catch</code> and the
      caught object declaration.
-->
      例外の書式は、<code>@</code> ラベルと開き括弧（<code>{</code>）の間にスペースを1つ入れて、1行につき<code>@</code> ラベル1つにしてください。また、<code>@catch</code> とキャッチされるオブジェクトの宣言との間にも、同じようにスペースを1つ入れてください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        If you must use Obj-C exceptions, format them as follows.  However, see
        <a href="#Avoid_Throwing_Exceptions">Avoid Throwing Exceptions</a> for
        reasons why you <b>should not</b> be using exceptions.
-->
        どうしてもObjective-Cの例外を使う必要があるなら、次のような書式にしてください。ただし、「<a href="#Avoid_Throwing_Exceptions">例外をスローするのを避ける</a>」を読んで、なぜ例外を<b>使うべきでない</b>か確認してください。
      </p>
      <CODE_SNIPPET>
        @try {
          foo();
        }
        @catch (NSException *ex) {
          bar(ex);
        }
        @finally {
          baz();
        }
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  
  <STYLEPOINT title="Protocols">
-->
  <STYLEPOINT title="プロトコル">
    <SUMMARY>
<!--
      There should not be a space between the type identifier and the name
      of the protocol encased in angle brackets.
-->
      タイプ識別子とかぎ括弧に包まれたプロトコル名の間にはスペースを入れるべきではありません。
    </SUMMARY>
    <BODY>
      <p>
<!--
        This applies to class declarations, instance variables, and method
        delcarations. For example:
-->
        これはクラス宣言、インスタンス変数、メソッド宣言に適用します。
      </p>
      <CODE_SNIPPET>
        @interface MyProtocoledClass : NSObject&lt;NSWindowDelegate&gt; {
         @private
          id&lt;MyFancyDelegate&gt; delegate_;
        }
        - (void)setDelegate:(id&lt;MyFancyDelegate&gt;)aDelegate;
        @end
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

</CATEGORY>

<!--
<CATEGORY title="Naming">
-->  
<CATEGORY title="命名規則">

  <p>
<!--
    Naming rules are very important in maintainable code. Objective-C method
    names tend to be very long, but this has the benefit that a block of code
    can almost read like prose, thus rendering many comments unnecessary. 
-->
    コードをメンテナンス可能にするためには、命名規則が極めて重要になります。Objective-Cのメソッド名は非常に長くなりがちですが、コードがまるで文章のように読めるという利点があります。そのおかげで、それほどコメントを入れる必要はないはずです。
  </p>
    <p> 
<!-- When writing pure Objective-C code, we mostly follow standard <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html">Objective-C
    naming rules</a>. These naming guidelines may differ
    significantly from those outlined in the C++ style guide. For example,
    Google's C++ style guide recommends the use of underscores between words
    in variable names, whereas this guide recommends the use of intercaps,
    which is standard in the Objective-C community.
-->
    純粋なObjective-Cのコードを書くときには、標準である<a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/CodingGuidelines.html">Objective-C naming rules</a>にほぼ準拠します。しかし、このAppleの命名ガイドラインは、GoogleのC++スタイルガイドで説明したものとは大きく異なっています。例えば、Google C++スタイルガイドでは、変数名には単語と単語の間にアンダースコア（_）を入れたものを使うよう推奨していますが、Appleのガイドラインでは、インターキャプス（intercaps）を使うよう推奨しています。Objective-Cの世界では、これが標準のやり方になっています。
  </p>
  <p>
<!--
    Any class, category, method, or variable name may use all capitals for
    <a href="http://en.wikipedia.org/wiki/Initialism">initialisms</a>
    within the name. This follows Apple's standard of using all capitals
    within a name for initialisms such as URL, TIFF, and EXIF.
-->
    クラス、カテゴリ、メソッド、変数の名前には、すべて大文字の<a href="http://en.wikipedia.org/wiki/Initialism">イニシャリズム</a>（<a href="http://ja.wikipedia.org/wiki/%E9%A0%AD%E5%AD%97%E8%AA%9E">頭字語</a>）を使っても構いません。URL、TIFF、EXIFなど、すべて大文字の頭字語を使うAppleの標準にしたがっています。
  </p>
  <p>
<!--
    When writing Objective-C++, however, things are not so cut and dry. Many
    projects need to implement cross-platform C++ APIs with some Objective-C
    or Cocoa, or bridge between a C++ back-end and a native Cocoa front-end.
    This leads to situations where the two guides are directly at odds.
-->
    ところが、Objective-C++のコードを書くときには、そう単純な話ではありません。Objective-CやCocoaとともに、クロスプラットフォーム用のC++ APIを実装したり、C++バックエンドとネイティブCocoaフロントエンド間のブリッジを実装したりする必要のあるプロジェクトもたくさんあります。このような場合には、これら2つのガイドラインが直接ぶつかってしまいます。
  </p>
  <p>
<!--
    Our solution is that the style follows that of the method/function being
    implemented. If you're in an <code>@implementation</code> block, use the
    Objective-C naming rules. If you're implementing a method for a C++
    <code>class</code>, use the C++ naming rules. This avoids the situation
    where instance variable and local variable naming rules are mixed within a
    single function, which would be a serious detriment to readability.
-->
    私たちがとった解決策は、実装しようとしているメソッド/関数のガイドラインにしたがう、というものです。<code>@implementation</code> ブロックの中なら、Objective-Cの命名規則を使いましょう。C++の <code>class</code> に含まれるメソッドを実装しているなら、C++の命名規則を使いましょう。こうすることで、ひとつの関数の中でインスタンス変数とローカル変数の命名規則が混在することはなくなります。異なる命名規則が混在すると、極めて読みにくいコードになってしまいます。
  </p>

<!--
  <STYLEPOINT title="File Names">
-->
  <STYLEPOINT title="ファイル名">
    <SUMMARY>
<!--
      File names should reflect the name of the class implementation that
      they contain - - including case. Follow the convention that your
      
      project
      uses.
-->
      ファイル名は、そのファイルに含まれるクラス実装の名前を反映したものにするべきです。これには大文字と小文字の違いも含みます。プロジェクトで使っている規約にしたがいましょう。
    </SUMMARY>
    <BODY>
      <p>
<!--
        File extensions should be as follows:
-->
        ファイルの拡張子は次のようにするべきです。
      </p>
      <table>
        <tr>
          <td><code>.h</code></td>
<!--
          <td>C/C++/Objective-C header file</td>
-->
          <td>C/C++/Objective-Cのヘッダファイル</td>
        </tr>
        <tr>
          <td><code>.m</code></td>
<!--
          <td>Objective-C implementation file</td>
-->
          <td>Objective-Cの実装ファイル</td>
        </tr>
        <tr>
          <td><code>.mm</code></td>
<!--
          <td>Objective-C++ implementation file</td>
-->
          <td>Objective-C++の実装ファイル</td>
        </tr>
        <tr>
          <td><code>.cc</code></td>
<!--
          <td>Pure C++ implementation file</td>
-->
          <td>純粋なC++の実装ファイル</td>
        </tr>
        <tr>
          <td><code>.c</code></td>
<!--
          <td>C implementation file</td>
-->
          <td>Cの実装ファイル</td>
        </tr>
      </table>
      <p>
<!--
        File names for categories should include the name of the class being
        extended, e.g. <code>GTMNSString+Utils.h</code> or
        <code>GTMNSTextView+Autocomplete.h</code>
-->
        カテゴリのためのファイルの名前には、拡張されるクラス名が含まれるべきです。例えば、<code>GTMNSString+Utils.h</code> や <code>GTMNSTextView+Autocomplete.h</code> とします。
      </p>
    </BODY>
  </STYLEPOINT>

  <STYLEPOINT title="Objective-C++">
    <SUMMARY>
<!--
      Within a source file, Objective-C++ follows the style of the
      function/method you're implementing.
-->
      Objective-C++のソースファイルでは、実装しようとしている関数/メソッドのスタイルに準拠してください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        In order to minimize clashes between the differing naming styles when
        mixing Cocoa/Objective-C and C++, follow the style of the method being
        implemented. If you're in an <code>@implementation</code> block, use
        the Objective-C naming rules. If you're implementing a method for a
        C++ <code>class</code>, use the C++ naming rules.
-->
        Cocoa/Objective-CとC++が混在するときには、異なる命名スタイルがぶつかるのを最小限にするため、実装しようとしているメソッドのスタイルにしたがってください。<code>@implementation</code> ブロックの中であれば、Objective-Cの命名規則を使いましょう。C++の <code>class</code> の中にあるメソッドを実装しているのであれば、C++の命名規則を使いましょう。
      </p>
      <CODE_SNIPPET>
        // file: cross_platform_header.h
        
        class CrossPlatformAPI {
         public:
          ...
          int DoSomethingPlatformSpecific();  // プラットフォームごとの実装
         private:
          int an_instance_var_;
        };
        
        // file: mac_implementation.mm
        #include "cross_platform_header.h"
        
        // Objective-Cの命名規則を使った、典型的なObjective-Cクラス
        @interface MyDelegate : NSObject {
         @private
          int instanceVar_;
          CrossPlatformAPI* backEndObject_;
        }
        - (void)respondToSomething:(id)something;
        @end
        @implementation MyDelegate
        - (void)respondToSomething:(id)something {
          // CocoaからC++バックエンドへのブリッジ
          instanceVar_ = backEndObject-&gt;DoSomethingPlatformSpecific();
          NSString* tempString = [NSString stringWithInt:instanceVar_];
          NSLog(@"%@", tempString);
        }
        @end
        
        // C++の命名規則を使った、C++クラスによるプラットフォーム固有の実装
        int CrossPlatformAPI::DoSomethingPlatformSpecific() {
          NSString* temp_string = [NSString stringWithInt:an_instance_var_];
          NSLog(@"%@", temp_string);
          return [temp_string intValue];
        }
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>
  
<!--  <STYLEPOINT title="Class Names">-->
  <STYLEPOINT title="クラス名">
    <SUMMARY>
<!--
      Class names (along with category and protocol names) should start as
      uppercase and use mixed case to delimit words.
-->
      クラス名（カテゴリ名やプロトコル名も同様）は、大文字で始めて、大文字と小文字を組み合わせて単語を区切った書式にするべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        In <em>application-level</em> code, prefixes on class names should
        generally be avoided. Having every single class with same prefix
        impairs readability for no benefit. When designing code to be shared
        across multiple applications, prefixes are acceptable and recommended
        (e.g. <code>GTMSendMessage</code>).
-->
        <em>アプリケーションレベル</em>のコードでは通常、クラス名にプレフィックスを付けるべきではありません。すべての単体クラスに同じプレフィックスを付けても、読みにくくなるだけで得られるものがないためです。複数のアプリケーションで共通に使うコードを設計している場合には、プレフィックスを付けるのが望ましく、付けることを推奨します。（例えば、<code>GTMSendMessage</code> とします）。
      </p>
      
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Category Names">-->
  <STYLEPOINT title="カテゴリ名">
    <SUMMARY>
<!--
      Category names should start with a 2 or 3 character prefix
      identifying the category as part of a project or open for general
      use. The category name should incorporate the name of the class it's
      extending.      
-->
      カテゴリ名は、あるプロジェクトの一部であること、あるいは汎用でオープンであることがわかるよう、2文字もしくは3文字のプレフィックスで始めるべきです。カテゴリ名には、そのカテゴリが拡張しているクラス名を盛り込むべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        For example, if we want to create a category on <code>NSString</code>
        for parsing, we would put the category in a file named
        <code>GTMNSString+Parsing.h</code>, and the category itself would be
        named <code>GTMStringParsingAdditions</code> (yes, we know the file
        name and the category name do not match, but this file could have many
        separate categories related to parsing). Methods in that category
        should share the prefix (<code>gtm_myCategoryMethodOnAString:</code>)
        in order to prevent collisions in Objective-C which only has a single
        namespace. If the code isn't meant to be shared and/or doesn't run in
        a different address-space, the method naming isn't quite as
        important.
-->
        例えば、<code>NSString</code> にパースのためのカテゴリを作成したいなら、<code>GTMNSString+Parsing.h</code> という名前のファイルにカテゴリを入れます。そして、カテゴリ名を <code>GTMStringParsingAdditions</code> とします（もちろん、ファイル名とカテゴリ名が一致していないことはわかっています。しかし、こうしておけば、パースに関連したさまざまなカテゴリをこのファイルに入れられます）。同じカテゴリにあるメソッドには、同じプレフィックス（<code>gtm_myCategoryMethodOnAString:</code>）を付けるべきです。こうしておくと、名前空間が1つしかないObjective-Cでも、名前の衝突が避けられます。コードを共有するつもりがなかったり、別のアドレス空間で実行されるのであれば、メソッドの命名はそれほど重要ではありません。
      </p>
      <p>
<!--
        There should be a single space between the class name and the opening
        parenthesis of the category.
-->
        クラス名とカテゴリの開き括弧の間にはスペースを1つ入れるべきです。
      </p>
    </BODY>
  </STYLEPOINT>
  
<!--  <STYLEPOINT title="Objective-C Method Names">-->
  <STYLEPOINT title="Objective-Cのメソッド名">
    <SUMMARY>
<!--
      Method names should start as lowercase and then use mixed case.
      Each named parameter should also start as lowercase.
-->
      メソッド名は小文字で始めて、それ以降は大文字と小文字を組み合わせたものにするべきです。名前付きパラメータも同じように、小文字で始めるべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        The method name should read like a sentence if possible, meaning you
        should choose parameter names that flow with the method name. (e.g.
        <code>convertPoint:fromRect:</code> or
        <code>replaceCharactersInRange:withString:</code>). See <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-BCIGIJJF">Apple's
        Guide to Naming Methods</a> for more details.
-->
        メソッド名はできるだけ文章のように読めるようにして、パラメータ名もメソッド名から続けて読めるようにするべきです。（例えば、<code>convertPoint:fromRect:</code> や <code>replaceCharactersInRange:withString:</code> とします）。詳しくは、<a href="http://developer.apple.com/documentation/Cocoa/Conceptual/CodingGuidelines/Articles/NamingMethods.html#//apple_ref/doc/uid/20001282-BCIGIJJF">Appleによるメソッドの命名ガイド</a>を参照してください。
      </p>
      <p>
<!--
        Accessor methods should be named the same as the variable they're
        "getting", but they should <em>not</em> be prefixed with the word
        "get". For example:
-->
        アクセサメソッドは「取得しようしている」変数と同じ名前にするべきです。"get" というプレフィックスを付けるべきでは<em>ありません</em>。
        <BAD_CODE_SNIPPET>
          - (id)getDelegate;  // 避けよう
        </BAD_CODE_SNIPPET>
        <CODE_SNIPPET>
          - (id)delegate;    // よい
        </CODE_SNIPPET>
      </p>
      <p>
<!--
        This is for Objective-C methods only. C++ method names and functions
        continue to follow the rules set in the C++ style guide.
-->
        このルールはObjective-Cのメソッドにだけ適用されます。C++のメソッド名や関数名はC++スタイルガイドにあるルールにしたがいます。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Variable Names">-->
  <STYLEPOINT title="変数名">
    <SUMMARY>
<!--
      Variables names start with a lowercase and use mixed case to delimit
      words. Class member variables have trailing underscores. For example:
      <var>myLocalVariable</var>, <var>myInstanceVariable_</var>. Members
      used for KVO/KVC bindings may begin with a leading underscore
      <i>iff</i> use of Objective-C 2.0's <code>@property</code> isn't
      allowed.
-->
      変数名は小文字で始めて、大文字と小文字を組み合わせて単語を区切った書式にしてください。クラスメンバ変数はアンダースコア（_）で終わってください。例えば、<var>myLocalVariable</var> や <var>myInstanceVariable_</var> とします。<i>もし</i>Objective-C 2.0の <code>@property</code> が使えない場合には、KVO/KVCバインディング用のメンバをアンダースコアで始めても構いません。
    </SUMMARY>
    <BODY>
<!--      <SUBSECTION title="Common Variable Names">-->
      <SUBSECTION title="共通の変数名">
        <p>
<!--
          Do <em>not</em> use Hungarian notation for syntactic attributes,
          such as the static type of a variable (int or pointer). Give as
          descriptive a name as possible, within reason. Don't worry about
          saving horizontal space as it is far more important to make your
          code immediately understandable by a new reader. For example:
-->
         スタティック型（intやポインタ）のような変数の構文上の属性に、ハンガリアン記法を使っては<em>いけません</em>。無理のない範囲で、できるだけわかりやすい名前にしてください。水平方向のスペースをけちってはいけません。新しくコードを読む人がすぐに理解できるようにすることの方が、はるかに重要なことです。
        </p>
        <BAD_CODE_SNIPPET>
          int w;     
          int nerr;          
          int nCompConns; 
          tix = [[NSMutableArray alloc] init];
          obj = [someObject object];
          p = [network port];
        </BAD_CODE_SNIPPET>
        <CODE_SNIPPET>
          int numErrors;                
          int numCompletedConnections; 
          tickets = [[NSMutableArray alloc] init];
          userInfo = [someObject object];
          port = [network port];
        </CODE_SNIPPET>
      </SUBSECTION>

<!--      <SUBSECTION title="Instance Variables">-->
      <SUBSECTION title="インスタンス変数">
        <p>
<!--
          Instance variables are mixed case and should be suffixed with a
          trailing underscore, e.g. <var>usernameTextField_</var>. However,
          we permit an exception when binding to a member variable using
          KVO/KVC and Objective-C 2.0 cannot be used (due to OS release 
          constraints). In this case, it is acceptable to prefix the variable
          with an underscore, per Apple's accepted practices for key/value 
          naming. If Objective-C 2.0 can be used, <code>@property</code> and
          <code>@synthesize</code> provide a solution that conforms to the
          naming guidelines.
-->
          インスタンス変数は大文字と小文字を組み合わせて、アンダースコアで終わるようにするべきです。例えば、<var>usernameTextField_</var> とします。しかし、KVO/KVCとObjective-C 2.0を使ったメンバ変数へのバインディングが使えないとき（OSによる制限のため）は例外です。この場合には、変数のプレフィックスとしてアンダースコアを付けても構いません。Appleは慣習として、key/valueの命名にこれを許しています。もしObjective-C 2.0が使えるのであれば、<code>@property</code> と <code>@synthesize</code> を使って、この命名ガイドラインにしたがってください。
        </p>
      </SUBSECTION>
      
<!--      <SUBSECTION title="Constants">-->
      <SUBSECTION title="定数">
        <p>
<!--
          Constant names (#defines, enums, const local variables, etc.) should
          start with a lowercase <var>k</var> and then use mixed case to
          delimit words, i.e. <var>kInvalidHandle</var>,
          <var>kWritePerm</var>.
-->
          定数名（#define、enum、constなローカル変数など）は小文字 <var>k</var> で始めて、大文字と小文字を組合せて単語を区切ります。例えば、<var>kInvalidHandle</var> や <var>kWritePerm</var> とします。
        </p>
      </SUBSECTION>
    </BODY>
  </STYLEPOINT>

</CATEGORY>

<!--<CATEGORY title="Comments">-->
<CATEGORY title="コメント">

  <p>
<!--
    Though a pain to write, they are absolutely vital to keeping our code
    readable. The following rules describe what you should comment and where.
    But remember: while comments are very important, the best code is
    self-documenting. Giving sensible names to types and variables is much
    better than using obscure names and then trying to explain them through
    comments.
-->
    コメントを書くのは苦痛ですが、コードを読みやすくするには不可欠です。以下に、どこにどんなコメントを書いておくべきか説明します。
    でも忘れないでください: コメントは非常に重要ですが、最高のコードとは自己文書化されたコードのことです。あいまいな名前を付けてコメントで説明しようとするよりも、型や変数に理にかなった名前を付けておく方がはるかによいことです。
  </p>
  <p>
<!--
    When writing your comments, write for your audience: the next
    
    contributor
    who will need to understand your code.  Be generous &#8212; the next
    one may be you!
-->
    コメントを書くときには、コードを読む人のために書いてください。つまりコードを理解する必要のある次のコントリビュータ（貢献してくれる人）のためです。親切心をもちましょう &#8212; 次のコントリビュータというのはあなた自身かもしれませんよ！
  </p>
  <p>
<!--
    Remember that all of the rules and conventions listed in the C++ Style
    Guide are in effect here, with a few additional points, below.
-->
    C++スタイルガイドで取り上げたルールや規約は、このガイドラインでもすべて有効だということを忘れないでください。ここでは追加したポイントについて取り上げています。
  </p>

<!--  <STYLEPOINT title="File Comments">-->
  <STYLEPOINT title="ファイルのコメント">
    <SUMMARY>
<!--
      Start each file with a copyright notice, followed by a
      description of the contents of the file.
-->
      各ファイルはまずコピーライト宣言から始めて、その後にファイルの説明を続けてください。
    </SUMMARY>
    <BODY>
<!--
      <SUBSECTION title="Legal Notice and Author Line">
-->
      <SUBSECTION title="Legal Noticeと作者に関する行">
        <p>
<!--
          Every file should contain the following items, in order:
-->
          すべてのファイルには、以下の項目を以下の順序で入れるべきです。
          <ul>
<!--
            <li>a copyright statement (for example,
                <code>Copyright 2008 Google Inc.</code>)</li>
            <li>a license boilerplate.  Choose the appropriate boilerplate
                for the license used by the project (for example,
                Apache 2.0, BSD, LGPL, GPL)</li>
-->
            <li>コピーライトに関する文 （例えば、
                <code>Copyright 2008 Google Inc.</code> など）</li>
            <li>ライセンスの決まり文句。そのプロジェクトで使うライセンスに合わせて決まり文句を選びます。（例えば、
                Apache 2.0, BSD, LGPL, GPL など）</li>
          </ul>
        </p>
        <p>
<!--
          If you make significant changes to a file that someone else
          originally wrote, add yourself to the author line. This can
          be very helpful when another
          
          contributor
          has questions about the file and needs to know whom to contact
          about it.
-->
          もともと他人が書いたファイルに大きな変更をしたときには、作者のところに自分の名前を追加してください。これは、他のコントリビュータがそのファイルについて質問したり、問い合わせ先を知りたいときに非常に役に立ちます。
        </p>
      </SUBSECTION>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Declaration Comments">-->
  <STYLEPOINT title="宣言のコメント">
    <SUMMARY>
<!--
      Every interface, category, and protocol declaration should have an
      accompanying comment describing its purpose and how it fits into the
      larger picture.
-->
      インタフェース、カテゴリ、プロトコルの宣言にはすべて、目的と全体における位置付けを説明するためのコメントを入れておくべきです。
    </SUMMARY>
    <BODY>
      <CODE_SNIPPET>
        // アプリケーションの起動終了の通知を処理する、NSApplication の Delegate。
        // メインのアプリコントローラによって所有される。
        @interface MyAppDelegate : NSObject {
          ...
        }
        @end
      </CODE_SNIPPET>
      <p>
<!--
        If you have already described an interface in detail in the
        comments at the top of your file feel free to simply state
        "See comment at top of file for a complete description", but
        be sure to have some sort of comment.
-->
        インタフェースの詳細について、すでにファイルの先頭で説明しているのであれば、"See comment at top of file for a complete description"（「詳しくはファイル先頭のコメントを参照」）と書いても構いません。ただし、必ず何かしらのコメントを入れておいてください。
      </p>
      <p>
<!--
        Additionally, each method in the public interface should have a
        comment explaining its function, arguments, return value, and any
        side effects.
-->
        さらに、パブリックインタフェースにあるメソッドには、その機能、引数、戻り値、すべての副作用について説明したコメントを入れるべきです。
      </p>
      <p>
<!--
        Document the synchronization assumptions the class makes, if
        any. If an instance of the class can be accessed by multiple
        threads, take extra care to document the rules and invariants
        surrounding multithreaded use.
-->
        もしクラスが想定している同期があるなら、それについても書いてください。もしクラスのインスタンスが複数のスレッドからアクセスされる可能性があれば、マルチスレッドの利用に関するルールや不変条件を明記するよう十分注意してください。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Implementation Comments">-->
	<STYLEPOINT title="実装のコメント">
    <SUMMARY>
<!--
      Use vertical bars to quote variable names and symbols in comments rather
      than quotes or naming the symbol inline.
-->
      コメント中に変数名やシンボルを引用するときには、引用符やシンボルをインラインで指定するのではなく、垂直バー（縦棒）を使ってください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        This helps eliminate ambiguity, especially when the symbol is a common
        word that might make the sentence read like it was poorly constructed.
        E.g. for a symbol "count":
-->
        こうしておけば、あいまいさがなくなります。特に、そのシンボルがよく見かける単語であり、下手に文章として読めてしまうときに有効です。
        例えば、シンボル "count" の場合:
      </p>
      <CODE_SNIPPET>
        // Sometimes we need |count| to be less than zero.
      </CODE_SNIPPET>
      <p>
<!--
        or when quoting something which already contains quotes
-->
        あるいは、すでに引用符が含まれているものを引用する場合:
      </p>
      <CODE_SNIPPET>
        // Remember to call |StringWithoutSpaces("foo bar baz")|
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Object Ownership">-->
    <STYLEPOINT title="オブジェクトのオーナーシップ">
    <SUMMARY>
<!--
      Make the pointer ownership model as explicit as possible when it falls
      outside the most common Objective-C usage idioms.  
-->
      一般的なObjective-Cから外れた使い方をしているときには、オーナーシップモデルをできる限り明確に示してください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Instance variable pointers to objects derived from NSObject are
        presumed to be retained, and should be documented as <b>weak</b> if
        they are not retained by the class. However, instance variables which
        are labeled as IBOutlets are presumed to not be retained by the class,
        and should be documented as <b>strong</b> if the class does retain
        them.
-->
        NSObjectから派生したオブジェクトを指すインスタンス変数ポインタは、そのクラスに保持されているものと見なされます。もしそのクラスが保持していないなら、<b>weak</b>（弱い参照）であることを明記しておくべきです。ただし、IBOutlet というラベルの付いたインスタンス変数は、そのクラスによって保持されていないものと見なされます。もしそのクラスが保持しているなら、<b>strong</b>（強い参照）であることを明記しておくべきです。
      </p>
      <p>
<!--
        Where instance variables are pointers to CoreFoundation, C++, and
        other non-Objective-C objects, they should always be documented in
        comments as strong or weak. Be mindful that support for automatic C++
        objects encapsulated in Objective-C objects is disabled by default, as
        described <a href="http://chanson.livejournal.com/154253.html">here</a>.
-->
        インスタンス変数が CoreFoundation や C++、Objective-C以外のオブジェクトへのポインタであるときには、strong であるか weak であるかをコメントに明記しておくべきです。C++オブジェクトをObjective-Cオブジェクトに自動的にカプセル化する機能がありますが、これはデフォルトでは無効になっていることに注意してください。これについては<a href="http://chanson.livejournal.com/154253.html">こちら</a>に説明があります。
      </p>
      <p>
<!--
        Examples of strong and weak documentation:
-->
        strong と weak の記述例
        <CODE_SNIPPET>
          @interface MyDelegate : NSObject {
           @private
            IBOutlet NSButton* okButton_;  // normal NSControl
            IBOutlet NSMenu* myContextMenu_;  // manually-loaded menu (strong)

            AnObjcObject* doohickey_;  // my doohickey
            MyController* controller_;  // so we can send msgs back (weak, owns me)

            // non-NSObject pointers...
            CWackyCPPClass* wacky_;  // some cross-platform object (strong)
            CFDictionaryRef* dict_;  // (strong)
          }
          @end
        </CODE_SNIPPET>
        <dl>
<!--
          <dt>strong</dt><dd>The object will be <code>retain</code>'d by this class</dd>
          <dt>weak</dt><dd>The object will be <b>not</b> be <code>retain</code>'d by this class
          (e.g. a delegate).</dd>
-->
          <dt>strong</dt><dd>オブジェクトはこのクラスによって <code>retain</code> されている</dd>
          <dt>weak</dt><dd>オブジェクトはこのクラスによって <code>retain</code> されて<b>いない</b>
     		（例: デリゲート）</dd>
        </dl>
      </p>
    </BODY>
  </STYLEPOINT>
  
</CATEGORY>

<!--<CATEGORY title="Cocoa and Objective-C Features">-->
  <CATEGORY title="CocoaとObjective-Cの機能">

<!--  <STYLEPOINT title="Member Variables Should Be @private">-->
    <STYLEPOINT title="メンバ変数は@privateにする">
    <SUMMARY>
<!--
      Member variables should be declared <code>@private</code>.
-->
     メンバ変数は <code>@private</code> と宣言しておくべきです。
    </SUMMARY>
    <BODY>
      <CODE_SNIPPET>
        @interface MyClass : NSObject {
         @private
          id myInstanceVariable_;
        }
        // public accessors, setter takes ownership
        - (id)myInstanceVariable;
        - (void)setMyInstanceVariable:(id)theVar;
        @end
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>
  
<!--  <STYLEPOINT title="Identify Designated Initializer">-->
  <STYLEPOINT title="指定イニシャライザがわかるようにする">
    <SUMMARY>
<!--
      Comment and clearly identify your designated initializer.
-->
      指定イニシャライザがわかるよう、コメントを入れてください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        It is important for those who might be subclassing your class that the
        designated initializer be clearly identified. That way, they only need
        to subclass a single initializer (of potentially several) to guarantee
        their subclass' initializer is called. It also helps those debugging
        your class in the future understand the flow of initialization code if
        they need to step through it.
-->
        あなたが作ったクラスをサブクラス化しようとする人にとって、指定イニシャライザが明確にわかることは重要です。指定イニシャライザがわかれば、（複数あるかもしれない）イニシャライザのうち1つをサブクラス化することで、サブクラスのイニシャライザを確実に呼び出すことができます。また、将来、他の誰かがあなたの作ったクラスをデバッグしなければならないとき、クラスの初期化の流れを理解するのにも役立ちます。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Override Designated Initializer">-->
  <STYLEPOINT title="指定イニシャライザを上書きする">
    <SUMMARY>
<!--
      When writing a subclass that requires an <code>init...</code> method,
      make <i>sure</i> you override the superclass' designated initializer.
--> 
      <code>init...</code> メソッドを必要とするサブクラスを書くときには、スーパークラスの指定イニシャライザを上書きしていることを<i>確認</i>してください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        If you fail to override the superclass' designated initializer, your
        initializer may not be called in all cases, leading to subtle and
        very difficult to find bugs.
-->
        スーパークラスの指定イニシャライザを上書きしていなければ、イニシャライザが呼び出される保証はありません。これはバグを見つけるのをやっかいにして、問題を非常に難しくします。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Overridden NSObject Method Placement"> -->
  <STYLEPOINT title="オーバーライドしたNSObjectメソッドを置く場所">
    <SUMMARY>
<!--
      It is strongly recommended and typical practice to place overridden
      methods of <code>NSObject</code> at the top of an
      <code>@implementation</code>.
-->
      オーバーライドした <code>NSObject</code> のメソッドは <code>@implementation</code> の一番上に置くのが典型的なプラクティスであり、そうすることを強く推奨します。
    </SUMMARY>
    <BODY>
<!--
      This commonly applies (but is not limited) to the <code>init...</code>,
      <code>copyWithZone:</code>, and <code>dealloc</code> methods.
      <code>init...</code> methods should be grouped together, followed by
      the <code>copyWithZone:</code> method, and finally the
      <code>dealloc</code> method.
-->
      これは <code>init...</code>、<code>copyWithZone:</code>、<code>dealloc</code>といったメソッドによく適用されます（これらに限りませんが）。
      <code>init...</code> メソッド群をひとまとめにして、その後に <code>copyWithZone:</code> メソッドが、最後に <code>dealloc</code> メソッドが続くようにするべきです。
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Initialization">-->
  <STYLEPOINT title="初期化">
    <SUMMARY>
<!--
      Don't initialize variables to <code>0</code> or <code>nil</code> in the
      init method; it's redundant.
-->
      init メソッド内で変数を <code>0</code> や <code>nil</code> で初期化してはいけません。これは冗長です。
    </SUMMARY>
    <BODY>
      <p>
<!--
        All memory for a newly allocated object is initialized to 0 (except
        for <var>isa</var>), so don't clutter up the <code>init</code> method
        by re-initializing variables to 0 or <code>nil</code>.
-->
        新しく割り当てられたオブジェクトのメモリは（<var>isa</var> を除いて）すべて 0 に初期化されます。したがって、0 や <code>nil</code> で変数を再初期化することで、<code>init</code> メソッドを肥大化させてはいけません。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Avoid +new"> -->
  <STYLEPOINT title="+newを避ける">
    <SUMMARY>
<!--
      Do not invoke the <code>NSObject</code> class method <code>new</code>,
      nor override it in a subclass. Instead, use <code>alloc</code> and
      <code>init</code> methods to instantiate retained objects.
-->
      <code>NSObject</code> のクラスメソッドである <code>new</code> を呼び出してはいけません。サブクラスで <code>new</code> をオーバーライドしてもいけません。保持されたオブジェクトをインスタンス化するためには、<code>alloc</code> と <code>init</code> メソッドを使ってください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Modern Objective-C code explicitly calls <code>alloc</code> and an
        <code>init</code> method to create and retain an object.  As the
        <code>new</code> class method is rarely used, it makes reviewing code
        for correct memory management more difficult.
-->
        最近のObjective-Cコードは、オブジェクトを保持するために、明示的に <code>alloc</code> と <code>init</code> メソッドを呼び出します。<code>new</code> クラスメソッドはめったに使われないので、 これを使うと正しいメモリ管理ができているかコードをレビューするのが難しくなります。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Keep the Public API Simple">-->
  <STYLEPOINT title="パブリックAPIをシンプルにしておく">
    <SUMMARY>
<!--
      Keep your class simple; avoid "kitchen-sink" APIs. If a method doesn't
      need to be public, don't make it so. Use a private category to prevent
      cluttering the public header.
-->
     クラスをシンプルにしておきましょう。「キッチンシンク」（いろいろなものを積め込んだような）APIにしてはいけません。メソッドをパブリックにする必要がなければ、パブリックにしてはいけません。プライベートカテゴリを使って、ヘッダがぐちゃぐちゃになるのを防ぎましょう。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Unlike C++, Objective-C doesn't have a way to differentiate between
        public and private methods &#8212; everything is public. As a result,
        avoid placing methods in the public API unless they are actually
        expected to be used by a consumer of the class. This helps reduce the
        likelihood they'll be called when you're not expecting it. This includes
        methods that are being overridden from the parent class. For internal
        implementation methods, use a category defined in the implementation
        file as opposed to adding them to the public header.
-->
        C++と違って、Objective-Cにはパブリックメソッドとプライベートメソッドを区別する手段がありません。すべてが公開されている状態になるのです。したがって、実際のところクラスの利用者に使われることを想定していないメソッドは、パブリックAPIに置かないようにしてください。こうしておけば、意図せずメソッドが呼び出される可能性を減らせます。これには親クラスから上書きされたメソッドも含まれます。内部実装であるメソッドについては、パブリックヘッダに追加するのではなく、実装ファイルに定義したカテゴリを使ってください。
      </p>
      <CODE_SNIPPET>
        // GTMFoo.m
        #import "GTMFoo.h"

        @interface GTMFoo (PrivateDelegateHandling)
        - (NSString *)doSomethingWithDelegate;  // プライベートメソッドの宣言
        @end

        @implementation GTMFoo(PrivateDelegateHandling)
        ...
        - (NSString *)doSomethingWithDelegate {
          // このメソッドの実装
        }
        ...
        @end
      </CODE_SNIPPET>
      <p>
<!--
        Before Objective-C 2.0, if you declare a method in the private
        <code>@interface</code>, but forget to implement it in the main
        <code>@implementation</code>, the compiler will <i>not</i> object.
        (This is because you don't implement these private methods in a
        separate category.) The solution is to put the functions within
        an <code>@implementation</code> that specifies the category.
-->
        Objective-C 2.0以前は、プライベート <code>@interface</code> でメソッドを宣言しておきながらメインの <code>@implementation</code> でメソッドを実装し忘れていても、コンパイラは何も警告<i>してくれません</i>。（個別のカテゴリの中でプライベートメソッドを実装していないためです。） これを解決するには、カテゴリを指定した <code>@implementation</code> に関数を置いてください。
      </p>
      <p>
<!--
        If you are using Objective-C 2.0, you should instead declare your
        private category using a <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_5.html#">class
        extension</a>, for example: 
-->
       もしObjective-C 2.0を使っているなら、代わりに <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_4_section_5.html#">クラスエクステンション</a>を使ってプライベートカテゴリを宣言するべきです。例えば、次のようにします。
      </p>
      <CODE_SNIPPET>
      @interface GMFoo () { ... }
      </CODE_SNIPPET>
      <p>
<!--
        which will guarantee that the declared methods are implemented in the
        <code>@implementation</code> section by issuing a compiler warning if
        they are not.
-->
        こうすると、宣言されたメソッドが <code>@implementation</code> セクションで実装されていることを保証できます。もし実装されていなければ、コンパイラが警告を出してくれます。
      </p>
      <p>
<!--
        Again, "private" methods are not really private. You could
        accidentally override a superclass's "private" method, thus making a
        very difficult bug to squash. In general, private methods should have
        a fairly unique name that will prevent subclasses from unintentionally
        overriding them.
-->
        もう一度言っておきます。「プライベート」メソッドは実際にはプライベートではありません。スーパークラスの「プライベート」メソッドをうっかり上書きしてしまうおそれもあります。これはつぶすのが非常に難しいバグになります。一般的に、プライベートメソッドは非常に独特な名前にしておくべきです。そうすれば、意図せずサブクラスで上書きしてしまうのを避けられます。
      </p>
      <p>
<!--
        Finally, Objective-C categories are a great way to segment a large
        <code>@implementation</code> section into more understandable chunks
        and to add new, application-specific functionality to the most
        appropriate class. For example, instead of adding "middle truncation"
        code to a random object in your app, make a new category on
        <code>NSString</code>).
-->
       結局、Objective-Cのカテゴリを使うのがすぐれた方法です。カテゴリを使うと、大きな <code>@implementation</code> セクションを理解しやすいブロックに分割することができ、アプリケーション特有の新機能を適切なクラスに追加することができます。例えば、アプリ内のオブジェクトに、行き当たりばったりに「両端一致」コードを追加する代わりに、<code>NSString</code> に新しいカテゴリを追加してください。
      </p>
    </BODY>
  </STYLEPOINT>
  
<!--  <STYLEPOINT title="#import and #include">-->
  <STYLEPOINT title="#importと#include">
    <SUMMARY>
<!--
      <code>#import</code> Objective-C/Objective-C++ headers, and
      <code>#include</code> C/C++ headers.
-->
      Objective-C/Objective-C++ヘッダには <code>#import</code> を、C/C++ヘッダには <code>#include</code> を使ってください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Choose between <code>#import</code> and <code>#include</code> based
        on the language of the header that you are including.
-->
        <code>#import</code> と <code>#include</code> のどちらを使うかは、インクルードするヘッダの言語に基づいて決めてください。
      </p>
      <ul>
<!--
        <li>When including a header that uses Objective-C or Objective-C++,
            use <code>#import</code>.</li>
        <li>When including a standard C or C++ header, use
            <code>#include</code>.  The header should provide its own <a href="cppguide.xml?showone=The__define_Guard#The__define_Guard">#define
            guard</a>.</li>
-->
        <li>Objective-CまたはObjective-C++を使っているヘッダをインクルードするときには、<code>#import</code> を使ってください。</li>
        <li>標準のCまたはC++ヘッダをインクルードするときには、<code>#include</code> を使ってください。これらのヘッダには <a href="cppguide.xml?showone=The__define_Guard#The__define_Guard">#define ガード</a> を入れておくべきです。</li>

      </ul>
      <p>
<!--
        Some Objective-C headers lack <code>#define</code> guards, and expect
        to be included only by <code>#import</code>.  As Objective-C headers
        may only be included in Objective-C source files and other Objective-C
        headers, using <code>#import</code> across the board is appropriate.
-->
       Objective-Cヘッダには、<code>#define</code> ガードがなくて <code>#import</code> でインクルードされることしか想定していないものもあります。Objective-Cヘッダは、Objective-Cソースファイルか他のObjective-Cヘッダにしかインクルードされないため、すべてにおいて <code>#import</code> を使うのがよいです。
      </p>
      <p>
<!--
        Standard C and C++ headers without any Objective-C in them can expect
        to be included by ordinary C and C++ files.  Since there is no
        <code>#import</code> in standard C or C++, such files will be
        included by <code>#include</code> in those cases.  Using
        <code>#include</code> for them in Objective-C source files as well
        means that these headers will always be included with the same
        semantics.
-->
        Objective-Cを含まない標準のCおよびC++ヘッダは、通常のCおよびC++ファイルにインクルードされることを想定しています。標準のCやC++には <code>#import</code> がないため、<code>#include</code> を使ってインクルードされます。Objective-Cソースファイルでこれらのヘッダに <code>#include</code> を使うということは、これらのヘッダは常に同じセマンティックスでインクルードされることになります。
      </p>
      <p>
<!--
        This rule helps avoid inadvertent errors in cross-platform
        projects.  A Mac developer introducing a new C or C++ header might
        forget to add <code>#define</code> guards, which would not cause
        problems on the Mac if the new header were included with
        <code>#import</code>, but would break builds on other platforms
        where <code>#include</code> is used.  Being consistent by using
        <code>#include</code> on all platforms means that compilation is
        more likely to succeed everywhere or fail everywhere, and avoids
        the frustration of files working only on some platforms.
-->
        このルールは、クロスプラットフォームのプロジェクトにおいて、うっかり間違ってしまうのを防ぐのに役立ちます。Mac開発者が新しくCやC++のヘッダを追加しようとして、<code>#define</code> ガードを入れるのを忘れることがあります。この新しいヘッダを <code>#import</code> を使ってインクルードしようとしても、Mac上では問題にはなりません。しかし、<code>#include</code> を使っている他のプラットフォームでは、ビルドに失敗してしまうでしょう。すべてのプラットフォームにおいて一貫して <code>#include</code> を使うと、どんなプラットフォームでも同じく、コンパイルは成功か失敗のどちらかになり、特定のプラットフォームでしか動作しないファイルを避けることができます。
      </p>
      <CODE_SNIPPET>
        #import &lt;Cocoa/Cocoa.h&gt;
        #include &lt;CoreFoundation/CoreFoundation.h&gt;
        #import "GTMFoo.h"
        #include "base/basictypes.h"
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Use Root Frameworks">-->
  <STYLEPOINT title="ルートフレームワークを使う">
    <SUMMARY>
<!--
      Include root frameworks over individual files.
-->
      個別のファイルではなくルートフレームワークをインクルードしてください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        While it may seem tempting to include individual system headers from a
        framework such as Cocoa or Foundation, in fact it's less work on the
        compiler if you include the top-level root framework. The root
        framework is generally pre-compiled and can be loaded much more
        quickly. In addition, remember to use <code>#import</code> rather than
        <code>#include</code>.
-->
       CocoaやFoundationといったフレームワークにあるシステムヘッダを個別にインクルードしたくなるかもしれませんが、実際には最上位のルートフレームワークをインクルードしても、ほとんどコンパイラの負荷にはなりません。ルートフレームワークは通常プリコンパイルされていて、非常に高速にロードできるためです。また、Objective-Cフレームワークには、<code>#include</code> ではなく <code>#import</code> を使うのを忘れないでください。
      </p>
      <CODE_SNIPPET>
        #import &lt;Foundation/Foundation.h&gt;     // よい
      </CODE_SNIPPET>
      <BAD_CODE_SNIPPET>
        #import &lt;Foundation/NSArray.h&gt;        // 避けよう
        #import &lt;Foundation/NSString.h&gt;
        ...
      </BAD_CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>
  
<!--  <STYLEPOINT title="Prefer To autorelease At Time of Creation">-->
  <STYLEPOINT title="生成時にautoreleaseすることを推奨">
    <SUMMARY>
<!--
      When creating new temporary objects, <code>autorelease</code> them on
      the same line as you create them rather than a separate
      <code>release</code> later in the same method.
-->
      一時的なオブジェクトを新しく生成するときには、そのメソッドの終わりの方で個別に <code>release</code> するのではなく、オブジェクトの生成と同じ行で <code>autorelease</code> しましょう。
    </SUMMARY>
    <BODY>
      <p>
<!--
        While ever so slightly slower, this prevents someone from accidentally
        removing the <code>release</code> or inserting a <code>return</code>
        before it and introducing a memory leak. E.g.:
-->
        ほんの少し遅くなりますが、うっかり <code>release</code> を消したり、<code>release</code> の前に <code>return</code> することでメモリリークが発生してしまうのを防ぐことができます。
      </p>
      <BAD_CODE_SNIPPET>
        // 避けよう（やむを得ないパフォーマンス上の理由がない限り）
        MyController* controller = [[MyController alloc] init];
        // ... リターンするかもしれないコード ...
        [controller release];
      </BAD_CODE_SNIPPET>
      <CODE_SNIPPET>
        // 望ましい
        MyController* controller = [[[MyController alloc] init] autorelease];
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Autorelease Then Retain">-->
  <STYLEPOINT title="autoreleaseしてからretainする">
    <SUMMARY>
<!--
      Assignment of objects follows the <code>autorelease</code> then
      <code>retain</code> pattern.
-->
     オブジェクトの代入には、<code>autorelease</code> してから <code>retain</code> する、というパターンを使いましょう。
    </SUMMARY>
    <BODY>
      <p>
<!--
        When assigning a new object to a variable, one must first release the
        old object to avoid a memory leak. There are several "correct" ways to
        handle this. We've chosen the "autorelease then retain" approach
        because it's less prone to error. Be aware in tight loops it can fill
        up the autorelease pool, and may be slightly less efficient, but we
        feel the tradeoffs are acceptable.
-->
        新しいオブジェクトを変数に代入するときには、メモリリークを起こさないよう、まず古いオブジェクトを解放する必要があります。これには「正しい」やり方がいくつかあります。ここでは、「autoreleaseしてからretainする」という方法を選びました。なぜなら、間違いにくいためです。タイトループでは、autorelease pool がいっぱいになって、効率が少し悪くなることに注意してください。それでも、このトレードオフは許容できると考えました。
      </p>
      <CODE_SNIPPET>
        - (void)setFoo:(GMFoo *)aFoo {
          [foo_ autorelease];  // |foo_| == |aFoo| であれば、deallocしない
          foo_ = [aFoo retain]; 
        }
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="dealloc should process instance variables in declaration                      order"> -->
  <STYLEPOINT title="インスタンス変数の宣言順にdeallocする">
    <SUMMARY>
<!--
      <code>dealloc</code> should process instance variables in the same order
      the <code>@interface</code> declares them, so it is easier for a reviewer
      to verify.
-->
      <code>@interface</code> に宣言したのと同じ順序で、インスタンス変数を <code>dealloc</code> するべきです。こうしておけば、レビューアが確認しやすくなります。
    </SUMMARY>
    <BODY>
      <p>
<!--
        A code reviewer checking a new or revised <code>dealloc</code>
        implementation needs to make sure that every retained instance
        variable gets released.
-->
        新規もしくは変更された <code>dealloc</code> の実装をチェックするため、コードレビューアは保持されたインスタンス変数がすべて解放されたか確認しなくてはなりません。
      </p>
      <p>
<!--
        To simplify reviewing <code>dealloc</code>, order the code so that
        the retained instance variables get released in the same order that
        they are declared in the <code>@interface</code>. If
        <code>dealloc</code> invokes other methods that release instance
        variables, add comments describing what instance variables those
        methods handle.
-->
        <code>dealloc</code> をレビューしやすくするため、<code>@interface</code> に宣言したのと同じ順序で保持されたインスタンス変数を解放してください。<code>dealloc</code> が他のメソッドを呼び出してインスタンス変数を解放している場合には、そのメソッドでどのインスタンス変数が解放されているのか、コメントに書いておきましょう。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Setters copy NSStrings">-->
  <STYLEPOINT title="セッタではNSStringをコピーする">
    <SUMMARY>
<!--
      Setters taking an <code>NSString</code>, should always <code>copy</code>
      the string it accepts.
-->
       <code>NSString</code> を引数に持つセッタは、受け取った文字列を必ず <code>copy</code> するべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Never just <code>retain</code> the string. This avoids the caller
        changing it under you without your knowledge. Don't assume that
        because you're accepting an <code>NSString</code> that it's not
        actually an <code>NSMutableString</code>.
-->
        文字列を <code>retain</code> するだけでは十分ではありません。文字列をコピーしておけば、知らないうちに呼び出し元が文字列を変更してしまうといった事態が避けられます。<code>NSMutableString</code> ではなく <code>NSString</code> を受け取っているから大丈夫だと考えてはいけません。
      </p>
      <CODE_SNIPPET>
        - (void)setFoo:(NSString *)aFoo {
          [foo_ autorelease];
          foo_ = [aFoo copy];
        }
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Avoid Throwing Exceptions">-->
  <STYLEPOINT title="例外をスローするのを避ける">
    <SUMMARY>
<!--
      Don't <code>@throw</code> Objective-C exceptions, but you should be
      prepared to catch them from third-party or OS calls.
-->
     Objective-Cの例外を <code>@throw</code> してはいけません。ただしサードパーティ製のコードやOS呼び出しからの例外は、キャッチできるようしておくべきです。
    </SUMMARY>
    <BODY>
      <p>
<!--
        We do compile with <code>-fobjc-exceptions</code> (mainly so we get
        <code>@synchronized</code>), but we don't <code>@throw</code>. Use of
        <code>@try</code>, <code>@catch</code>, and <code>@finally</code> are
        allowed when required to properly use 3rd party code or libraries. If
        you do use them please document exactly which methods you expect to
        throw.
-->
        私たちは <code>-fobjc-exceptions</code> を付けてコンパイルしていますが、これは主に <code>@synchronized</code> を使うためであり、<code>@throw</code> は使っていません。もしサードパーティ製のコードやライブラリを正しく使うために必要であれば、<code>@try</code>、<code>@catch</code>、<code>@finally</code> を使っても構いません。例外を使うのであれば、どのメソッドが例外をスローする可能性があるのか正確に記載してください。
      </p>
      <p>
<!--
        Do not use the <code>NS_DURING</code>, <code>NS_HANDLER</code>,
        <code>NS_ENDHANDLER</code>, <code>NS_VALUERETURN</code> and
        <code>NS_VOIDRETURN</code> macros unless you are writing code that
        needs to run on MacOS 10.2 or before.
-->
        Mac OS X 10.2以前で動かす必要のあるコードを書いていない限り、<code>NS_DURING</code>、<code>NS_HANDLER</code>、<code>NS_ENDHANDLER</code>、<code>NS_VALUERETURN</code>、<code>NS_VOIDRETURN</code> といったマクロを使ってはいけません。
      </p>
      <p>
<!--
        Also be aware when writing Objective-C++ code that stack based objects
        are <b>not</b> cleaned up when you throw an Objective-C exception.
        Example:
-->
        また、Objective-C++のコードを書いているときには、Objective-Cの例外をスローするとスタックベースのオブジェクトは解放され<b>ない</b>ことを認識しておいてください。例:
      </p>
      <CODE_SNIPPET>
        class exceptiontest {
         public:
          exceptiontest() { NSLog(@"Created"); }
          ~exceptiontest() { NSLog(@"Destroyed"); }
        };

        void foo() {
          exceptiontest a;
          NSException *exception = [NSException exceptionWithName:@"foo"
                                                           reason:@"bar"  
                                                         userInfo:nil];
          @throw exception;
        }

        int main(int argc, char *argv[]) {
          GMAutoreleasePool pool;
          @try {
            foo();
          }
          @catch(NSException *ex) {
            NSLog(@"exception raised");
          }
          return 0;
        }
      </CODE_SNIPPET>
      <p>
<!--
        will give you:
-->
        出力は次のようになります。
      </p>
      <CODE_SNIPPET>
        2006-09-28 12:34:29.244 exceptiontest[23661] Created
        2006-09-28 12:34:29.244 exceptiontest[23661] exception raised
      </CODE_SNIPPET>
      <p>
<!--
        Note that the destructor for <i>a</i> never got called. This is a
        major concern for stack based smartptrs such as
        <code>shared_ptr</code> and <code>linked_ptr</code>, as well as any
        STL objects that you may want to use. Therefore it pains us to say
        that if you must use exceptions in your Objective-C++ code, use C++
        exceptions whenever possible. You should never re-throw an Objective-C
        exception, nor are stack based C++ objects (such as
        <code>std::string</code>, <code>std::vector</code> etc.) allowed in
        the body of any <code>@try</code>, <code>@catch</code>, or
        <code>@finally</code> blocks.
-->
        オブジェクト <i>a</i> のデストラクタは呼び出されないことに注意してください。これは <code>shared_ptr</code> や <code>linked_ptr</code> といったスタックベースのスマートポインタや、利用するかもしれない STL オブジェクトにとって、大きな懸念です。言いにくいことですが、Objective-C++のコードで例外を使う必要があるのなら、できる限りC++の例外を使うようにしてください。Objective-Cの例外を再びスローすべきではありません。また、スタックベースのC++オブジェクト（<code>std::string</code> や <code>std::vector</code> など）を、<code>@try</code>、<code>@catch</code>、<code>@finally</code> といったブロック本体で使ってはいけません。
      </p>
    </BODY>
  </STYLEPOINT>


<!--  <STYLEPOINT title="nil Checks">-->
  <STYLEPOINT title="nilチェック">
    <SUMMARY>
<!--
      Use <code>nil</code> checks for logic flow only.
-->
      <code>nil</code> チェックはロジックフローのためだけに使ってください。
    </SUMMARY>
    <BODY>
      <p>
<!--
        Use <code>nil</code> checks for logic flow of the application, not for
        crash prevention. Sending a message to a <code>nil</code> object is
        handled by the Objective-C runtime. If the method has no return
        result, you're good to go. However if there is one, there may be
        differences based on runtime architecture, return size, and OS X
        version (see <a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_2_section_3.html#//apple_ref/doc/uid/TP30001163-CH11-SW7">Apple's
        documentation</a> for specifics).
-->
        <code>nil</code> チェックはクラッシュ防止のためでなく、アプリケーションのロジックフローのためだけに使ってください。<code>nil</code> オブジェクトへのメッセージ送信は、Objective-Cランタイムによって処理されます。そのメッセージに戻すべき結果がなければ、何ごともなかったように進みます。結果があっても、ランタイムアーキテクチャ、リターンサイズ、OS Xのバージョンによって動作は異なるかもしれません。（詳しくは、<a href="http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/chapter_2_section_3.html#//apple_ref/doc/uid/TP30001163-CH11-SW7">Appleのドキュメント</a>を参照してください）
      </p>
      <p>
<!--
        Note that this is very different from checking C/C++ pointers against
        <code>NULL</code>, which the runtime does not handle and will cause
        your application to crash. You still need to make sure you do not
        dereference a <code>NULL</code> pointer.
-->
        これはC/C++ポインタを <code>NULL</code> チェックするのとはまったく違うことに注意してください。C/C++ポインタの場合、ランタイムは<code>NULL</code>を処理できないため、<code>NULL</code> チェックをしないとアプリケーションはクラッシュしてしまいます。したがって、<code>NULL</code> ポインタをデリファレンスしないよう確認する必要があるのです。
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="BOOL Pitfalls">-->
  <STYLEPOINT title="BOOLの落とし穴">
    <SUMMARY>
<!--
      Be careful when converting general integral values to <code>BOOL</code>.
      Avoid comparing directly with <code>YES</code>.
-->
      通常の整数値を <code>BOOL</code> 型に変換するときには注意してください。<code>YES</code> と直接比較してはいけません。
    </SUMMARY>
    <BODY>
      <p>
<!--
        <code>BOOL</code> is defined as an unsigned char in Objective-C which
        means that it can have values other than <code>YES</code> (1) and
        <code>NO</code> (0). Do not cast or convert general integral values
        directly to <code>BOOL</code>. Common mistakes include casting or
        converting an array's size, a pointer value, or the result of a bitwise
        logic operation to a <code>BOOL</code> which, depending on the value of
        the last byte of the integral result, could still result in a
        <code>NO</code> value. When converting a general integral value to a
        <code>BOOL</code> use ternery operators to return a <code>YES</code>
        or <code>NO</code> value.
-->
        Objective-Cでは、<code>BOOL</code> 型は unsigned charとして定義されています。つまり、<code>YES</code> (1) と  <code>NO</code> (0) 以外の値を取り得るということです。通常の整数値を直接 <code>BOOL</code> 型にキャストしたり、変換しようとしてはいけません。よくある間違いとして、配列のサイズやポインタ値、<code>BOOL</code> に対するビット論理の結果をキャストしてしまうことがあります。これらは、整数値の最後のバイト値によって、常に <code>NO</code> になるおそれがあります。通常の整数値を <code>BOOL</code> に変換するときには、<code>YES</code> か <code>NO</code> の値を返す三項オペレータを使ってください。
      </p>
      <p>
<!--
        You can safely interchange and convert <code>BOOL</code>,
        <code>_Bool</code> and <code>bool</code> (see C++ Std 4.7.4, 4.12 and
        C99 Std 6.3.1.2). You cannot safely interchange <code>BOOL</code> and
        <code>Boolean</code> so treat <code>Booleans</code> as a general
        integral value as discussed above. Only use <code>BOOL</code> in
        Objective C method signatures.
-->
        <code>BOOL</code>、<code>_Bool</code>、<code>bool</code> は、安全に置き換え、変換が可能です（ C++標準 4.7.4、4.12 および C99標準 6.3.1.2を参照）。<code>BOOL</code> と <code>Boolean</code> は安全に置き換えられないため、先ほど説明したように <code>Boolean</code> を通常の整数値として扱ってください。Objective Cのメソッドシグニチャには、<code>BOOL</code> だけを使ってください。
      </p>
      <p>
<!--
        Using logical operators (<code>&amp;&amp;</code>, <code>||</code> and
        <code>!</code>) with <code>BOOL</code> is also valid and will return
        values that can be safely converted to <code>BOOL</code> without the
        need for a ternery operator.
-->
        <code>BOOL</code> とともに、論理オペレータ（<code>&amp;&amp;</code>、<code>||</code>、<code>!</code>）を使うこともできます。これを使うと、三項オペレータを使わなくても、安全に <code>BOOL</code> に変換された値を返せます。
      </p>
      <BAD_CODE_SNIPPET>
        - (BOOL)isBold {
          return [self fontTraits] &amp; NSFontBoldTrait;
        }
        - (BOOL)isValid {
          return [self stringValue];
        }
      </BAD_CODE_SNIPPET>
      <CODE_SNIPPET>
        - (BOOL)isBold {
          return ([self fontTraits] &amp; NSFontBoldTrait) ? YES : NO;
        }
        - (BOOL)isValid {
          return [self stringValue] != nil;
        }
        - (BOOL)isEnabled {
          return [self isValid] &amp;&amp; [self isBold];
        }
      </CODE_SNIPPET>
      <p>
<!--
        Also, don't directly compare <code>BOOL</code> variables directly
        with <code>YES</code>. Not only is it harder to read for those
        well-versed in C, the first point above demonstrates that return
        values may not always be what you expect.
-->
        また、<code>BOOL</code> 型の変数を <code>YES</code> と直接比較してはいけません。Cに慣れた人にとって読みにくいだけでなく、最初に指摘したように戻り値が期待したものになるとは限りません。
      </p>
      <BAD_CODE_SNIPPET>
        BOOL great = [foo isGreat];
        if (great == YES)
          // ... great!
      </BAD_CODE_SNIPPET>

      <CODE_SNIPPET>
        BOOL great = [foo isGreat];
        if (great)
          // ... great!
      </CODE_SNIPPET>
    </BODY>
  </STYLEPOINT>
  
<!--  <STYLEPOINT title="Properties">-->
  <STYLEPOINT title="プロパティ">
    <SUMMARY>
<!--
      Properties in general are allowed with the following caveat: properties
      are an Objective-C 2.0 feature which will limit your code to running
      on the iPhone and MacOS X 10.5 (Leopard) and higher. Dot notation
      is allowed only for access to a declared <code>@property</code>.
-->
      一般的にプロパティを使うときには以下のことに注意してください。プロパティはObjective-C 2.0の機能であり、プロパティを使ったコードはiPhoneやMac OS X 10.5（Leopard）以上でしか動きません。ドット記法が使えるのは、宣言された <code>@property</code> にアクセスするときだけです。
    </SUMMARY>
    <BODY> 
<!--      <SUBSECTION title="Naming">-->
      <SUBSECTION title="命名規則">
        <p>
<!--
          A property's associated instance variable's name must conform to the
          trailing _ requirement. The property's name should be the same as its
          associated instance variable without the trailing _. The optional
          space between the <code>@property</code> and the opening parenthesis
          should be omitted, as seen in the examples.
-->
          プロパティに対応するインスタンス変数名は、アンダースコア（_）で終わらなければなりません。プロパティ名は、対応するインスタンス変数名から最後のアンダースコア（_）を取り除いたものにするべきです。<code>@property</code> と開き括弧の間のスペースは、例にあるように省略するべきです。
        </p>
        <p>
<!--
          Use the @synthesize directive to rename the property correctly.
-->
           @synthesize ディレクティブを使ってプロパティの名前を変更してください。
        </p>
    
        <CODE_SNIPPET>
          @interface MyClass : NSObject {
           @private
            NSString *name_;
          }
          @property(copy, nonatomic) NSString *name;
          @end
          
          @implementation MyClass
          @synthesize name = name_;
          @end
        </CODE_SNIPPET>
      </SUBSECTION>
<!--      <SUBSECTION title="Location"> -->
      <SUBSECTION title="場所">
        <p>
<!--
          A property's declaration must come immediately after the instance
          variable block of a class interface. A property's definition must
          come immediately after the <code>@implementation</code> block in a
          class definition. They are indented at the same level as the 
          <code>@interface</code> or <code>@implementation</code> statements
          that they are enclosed in.
-->
          プロパティ宣言はクラスインタフェースのインスタンス変数ブロックの直後に置くべきです。プロパティ定義はクラス定義の <code>@implementation</code> ブロックの直後に置くべきです。これらは、まわりにある <code>@interface</code> や <code>@implementation</code> と同じレベルにインデントしてください。
        </p>
        <CODE_SNIPPET>
          @interface MyClass : NSObject {
           @private
            NSString *name_;
          }
          @property(copy, nonatomic) NSString *name;
          @end
          
          @implementation MyClass
          @synthesize name = name_;
          - (id)init {
          ...
          }
          @end
        </CODE_SNIPPET>
      </SUBSECTION>
<!--      <SUBSECTION title="Use Copy Attribute For Strings">-->
      <SUBSECTION title="文字列にはcopy属性を使う">
        <p>
<!--
          NSString properties should always be declared with the
          <code>copy</code> attribute.
-->
          NSStringプロパティには、必ず <code>copy</code> 属性を宣言するべきです。
        </p>
        <p>
<!--
          This logically follows from the requirement that setters for
          NSStrings always must use <code>copy</code> instead of
          <code>retain</code>.
-->
          これは、NSStringのセッタには必ず <code>retain</code> の代わりに <code>copy</code> を使わなければならない、というルールに論理的にしたがったものです。
        </p>
      </SUBSECTION>
<!--      <SUBSECTION title="Never synthesize CFType properties">-->
      <SUBSECTION title="CFTypeプロパティはsynthesizeしてはいけない">
        <p>
<!--
          CFTypes should always have the <code>@dynamic</code> implementation
          directive. 
-->
          CFType には必ず <code>@dynamic</code> 実装ディレクティブを付けるべきです。
        </p>
        <p>
<!--
          Since CFTypes can't have the <code>retain</code> property
          attribute, the developer must handle retaining and releasing the
          value themselves. In the rare case that you do actually want
          assignment it is better to make that completely clear by actually
          implementing the setter and getter and commenting why that is the
          case.
-->
          CFType は <code>retain</code> プロパティ属性を持てないため、開発者が自分でその値をretainしたりreleaseしなければなりません。まれに代入したいときもありますが、その場合には、実際にセッタやゲッタを実装して、その理由をコメントに明記しておくのが望ましいです。
        </p>
      </SUBSECTION>
<!--      <SUBSECTION title="List out all implementation directives">-->
      <SUBSECTION title="実装ディレクティブをすべて列挙する">
        <p>
<!--
          Use implementation directives for all properties even if they are
          <code>@dynamic</code> by default.
-->
          デフォルトの <code>@dynamic</code> であったとしても、すべてのプロパティに実装ディレクティブを付けてください。
        </p>
        <p>
<!--
          Even though <code>@dynamic</code> is default, explicitly list it out
          with all of the other property implementation directives making it
          clear how every property in a class is handled at a single glance.
-->
          たとえ <code>@dynamic</code> がデフォルトだとしても、クラスのプロパティがそれぞれどのように処理されるのか一目でわかるよう、プロパティの実装ディレクティブはすべて明示的に列挙してください。
        </p>
        <BAD_CODE_SNIPPET>
          @interface MyClass : NSObject
          @property(readonly) NSString *name;
          @end
          
          @implementation MyClass
          .
          .
          .
          - (NSString*)name {
            return @"foo";
          }
          @end
        </BAD_CODE_SNIPPET>
        <CODE_SNIPPET>
          @interface MyClass : NSObject
          @property(readonly) NSString *name;
          @end
          
          @implementation MyClass
          @dynamic name;
          .
          .
          .
          - (NSString*)name {
            return @"foo";
          }
          @end
        </CODE_SNIPPET>
      </SUBSECTION>
<!--      <SUBSECTION title="Atomicity">-->
      <SUBSECTION title="アトミック性">		
        <p>
<!--
          Be aware of the overhead of properties. By default, all synthesized
          setters and getters are atomic. This gives each set and get calls a
          substantial amount of synchronization overhead. Declare your
          properties <code>nonatomic</code> unless you require atomicity.
-->
          プロパティにはオーバーヘッドがあることを認識しておいてください。デフォルトでは、同期のセッタとゲッタはすべてアトミックになります。そのため、セットとゲットの呼び出しには同期オーバーヘッドがかなりあります。アトミック性が必要ないなら、プロパティを <code>nonatomic</code> と宣言しておいてください。
        </p>

      </SUBSECTION>
<!--      <SUBSECTION title="Dot notation">-->
      <SUBSECTION title="ドット記法">
        <p>
<!--
          Dot notation is idiomatic style for Objective-C 2.0. It may be used
          when doing simple operations to get and set a <code>@property</code>
          of an object, but should not be used to invoke other object behavior.
-->
          ドット記法はObjective-C 2.0の慣用スタイルです。オブジェクトの <code>@property</code> をget/setするために単純な操作をするときには使っても構いませんが、他のオブジェクトの挙動を呼び出すために使うべきではありません。
        </p>
        <CODE_SNIPPET>
          NSString *oldName = myObject.name;
          myObject.name = @"Alice";
        </CODE_SNIPPET>
        <BAD_CODE_SNIPPET>
          NSArray *array = [[NSArray arrayWithObject:@"hello"] retain];

          NSUInteger numberOfItems = array.count;  // プロパティではない
          array.release;                           // プロパティではない
        </BAD_CODE_SNIPPET>
      </SUBSECTION>
    </BODY>
  </STYLEPOINT>
</CATEGORY>


<!--<CATEGORY title="Cocoa Patterns">-->
<CATEGORY title="Cocoaパターン">
  
<!-- <STYLEPOINT title="Delegate Pattern">-->
  <STYLEPOINT title="Delegateパターン">
    <SUMMARY>
<!--
      Delegate objects should not be retained.
-->
      Delegateオブジェクトをretainするべきではありません。
    </SUMMARY>
    <BODY>
      <p>
<!--
        A class that implements the delegate pattern should:
-->
        Delegateパターンを実装するクラスは、次のようにするべきです。
        <ol>
          <li>
<!--
            Have an instance variable named <var>delegate_</var> to reference
            the delegate.
-->
            delegateを参照する <var>delegate_</var> という名前のインスタンス変数を用意します。
          </li>
          <li>
<!--
            Thus, the accessor methods should be named <code>delegate</code>
            and <code>setDelegate:</code>.
-->
            次に、アクセサメソッドを <code>deletate</code> と <code>setDelegate:</code> という名前にします。
          </li>
          <li>
<!--
            The <var>delegate_</var> object should <b>not</b> be retained.
-->
            <var>delegate_</var> オブジェクトをretainするべきでは<b>ありません</b>。
          </li>
        </ol>
      </p>
    </BODY>
  </STYLEPOINT>

<!--  <STYLEPOINT title="Model/View/Controller">-->
  <STYLEPOINT title="Model/View/Controller">
    <SUMMARY>
<!--
      Separate the model from the view. Separate the controller from the
      view and the model. Use <code>@protocol</code>s for callback APIs.
-->
      モデルをビューから分離しましょう。コントローラをビューとモデルから分離しましょう。コールバックAPIには <code>@protocol</code> を使ってください。
    </SUMMARY>
    <BODY>
      <p>
        <ul>
          <li>
<!--
            Separate model from view: don't build assumptions about the
            presentation into the model or data source. Keep the interface
            between the data source and the presentation abstract. Don't give
            the model knowledge of its view. (A good rule of thumb is to ask
            yourself if it's possible to have multiple presentations, with
            different states, on a single instance of your data source.)
-->
            モデルをビューから分離する: モデルやデータソースでは、プレゼンテーションについて何かを仮定してはいけません。データソースとプレゼンテーションとの間のインタフェースは、抽象化しておいてください。ビューに関するモデル知識を与えてはいけません。（データソースのインスタンスを1つ考えて、さまざまな状態のプレゼンテーションが複数可能かどうかを考えるのは、よい経験則です。）
          </li>
          <li>
<!--
            Separate controller from view and model: don't put all of the
            "business logic" into view-related classes; this makes the code
            very unusable. Make controller classes to host this code, but
            ensure that the controller classes don't make too many assumptions
            about the presentation.
-->
            コントローラをビューとモデルから分離する: すべての「ビジネスロジック」をビュー関連のクラスに入れてはいけません。こうしてしまうと、そのコードはほとんど他に使い道がなくなってしまいます。こうしたコードはコントローラクラスに入れてください。ただし、コントローラクラスでは、プレゼンテーションについてあまり多くを仮定してはいけません。
          </li>
          <li>
<!--
            Define callback APIs with <code>@protocol</code>, using
            <code>@optional</code> if not all the methods are required.
            (Exception: when using Objective-C 1.0, <code>@optional</code> isn't
            available, so use a category to define an "informal protocol".)
-->
            コールバックAPIは <code>@protocol</code> を使って定義してください。そして、もし必須でないメソッドがあれば、<code>@optional</code> を使ってください。
           （例外: Objective-C 1.0では <code>@optional</code> が使えないので、カテゴリを使って「非公式プロトコル」を定義してください。）
          </li>
        </ul>
      </p>
    </BODY>
  </STYLEPOINT>

</CATEGORY>

<HR/>

<p align="right">
Revision 2.24
</p>



<address>
Mike Pinkerton <br/>
Greg Miller <br/>
Dave MacLachlan <br/>
（日本語訳 <a href="http://www.textdrop.net/">Takashi Sasai</a>）
</address>
</GUIDE>

