はじめに
Xcode 8.2で型の不整合を警告されました(8.2固有の話ではありませんが)。いずれも書式側の型の見直しで解決しました。
Format specifies type 'long' but the argument has type 'int _Nullable'
原因
書式がlong型を明示していますが、この引数はint _Nullable型なので、不整合になっています。その警告が出ています。
善処例
before
[NSString stringWithFormat:@"Error code %ld", [transaction.error code]
after
[NSString stringWithFormat:@"Error code %zd", [transaction.error code]
Values of type 'NSInteger' should not be used as format arguments; add an explicit cast to 'long' instead
原因
'NSInteger'型の値は書式引数として使われるべきではないことが指摘されています。Xcodeがヒントとして、long型への明示的なキャストを加えるように示しています。
そもそも、long型の値にして表示する必要がなければ、むしろ書式自体を修正すべきですね。
善処例
before
[NSString stringWithFormat:@"Error code %ld", error.code]
after_xcode
[NSString stringWithFormat:@"Error code %ld", (long)error.code]
after
[NSString stringWithFormat:@"Error code %zd", error.code]