LoginSignup
7
3

More than 3 years have passed since last update.

はじめに

いまだにObjective-Cを使ってます。
なぜって11年前にリリースしたアプリをまだメンテナンスしてるから。
iOSソリティアV

悲しいです。:sob:

しかし結構稼いでくれるので、我慢。

やり方

Objective-Cでも最近は__auto_typeという型推論の機能があり、それを使う。
GCCの文法拡張なのかな。気にしないけど。

#define var __auto_type

なのをどこかに定義しておいて、

    var bounds = xxController.backView.bounds;
    if (bounds.size.width<bounds.size.height){
        ...
    }

ちゃんと使えます。素敵すぎる。:grin:

    NSArray*list = ...;
    var item = (NSNumber*)list[1];

NSArrayとかの時はキャストして使う。

    NSArray<NSNumber*>*list = ...;
    var item = list[1];
    if (item.boolValue){        
        //...
    }

xcode12だと以前はできなかった、これもOK!
今試してよかった。
しかしブロック構文変数の定義とかには使えない・・・と思ったらxcode12ではできる。やった:v:

    var r = ^(){
        ...
    };
    r();

最後に

Objective-CのNS標準クラス名、長ったらしいのが多いので、これ使うと結構幸せ:blush:
ソースの文字数も減るので、見やすくなる。

今回も手抜き記事。

以上!!!

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3