Xcode 4.4


先日、AppleのOSであるMac OS X 10.8 "Mountain Lion"が発売されたが、私の興味はもっぱらXcodeの新版であるXcode 4.4である。
マイナーバージョンアップであり、ぱっと見では違いが分かり難いのだが、実は大きく変わっている。

・The compiler automatically calls @synthesize by default for unimplemented @properties.
 自動プロパティ@propertyだが、必ずimplementationに対になる@synthesizeを記述する必要があったのが省略できるようになった。

・For the NSArray and NSDictionary classes, support is provided for Objective-C literals.
 NSArray 、NSDictionaryの初期化にリテラルを指定できるようになった。

NSArray* arry = @[ @"hello", @3 ];
NSDictionary* dict = 
@{
  @"名前": @"kazz",
  @"職種": @"プログラマ"
};

なお、以前の文法のようにnilで終端する必要も無くなった (Mutableの場合は明示的な指定が必要)※

・Subscripting using '[ ]' syntax is supported for Objective-C container objects.
 コンテナ(リスト、ディクショナリ)に対して"[" "]"ブラッケットに添え字で指定した(Subscripting)要素を参照、更新することができる。

arry[0] = @"hello";
arry[1] = @3;
dict[@"名前"] = @"kazz";
dict[@"職種"] = @"プログラマ";

・Compatibility with the C++11 standard is improved.
 C++11準拠、互換性の改善

・New static analyzer checks for common security mistakes in API and malloc usages.
 静的がアナライザがmallocの一般的なセキュリティリスク(バッファオーパフローのこと?)をチェックするようになった。

・The caller and callee for selected methods can be displayed in the Assistant Editor.
 ごめんなさい、よく分からなかったです。

・Code completion is enhanced with QuickHelp.
 コードコンプリション(補完)がQuickHelpにより拡張された (補完候補の概略を表示する)

・Scene Kit is supported with a viewer-editor for 3D document files.
 Scene Kitが3D Dicumet Filesを扱うためのビューワー/エディタをサポートするようになった。

・Improved localization workflow uses base language .xib files.
 .xibファイルを使ったローカライズのワークフローが改善された (まだ試していないのでよく解らない)

・Git supports staging of individual changes.
 Gitが個々の変更のステージングをサポートするようになった

とてんこ盛りである。

特にLLVM4.0の機能を利用したClang拡張による""Modern Objective-C"と呼ばれるliteral syntaxの数々は、読みやすい、書きやすいとは言えなかったObjective-Cのコーディング/リーディングを改善してくれるのではないだろうか。

バージョン4.4における変更点の詳細に関してこちらを参照のこと
What's New In Xcode: New Features in Xcode 4.4

※ここでは省かれているが、実際にはコレクション以外のNSNumberもNSStingクラスのように定数で初期化することができるようになった。

NSNumber* n1 = @1000;     //[NSNumber numberWithInt:1000] 
NSNumber* n2 = @3.1415926;//[NSNumber numberWithDouble:3.1415926]
NSNumber* b = @YES;       //[NSNumber numberWithBool:YES]

NSNumber *f = @2.5f;  //float
NSNumber *nu = @256u; //unsigned

これはかなり楽になる。