公式のNSLogまとめがきた。
そして DEBUG マクロの使い方。
- (void)pressButton:(id)sender
{
#if DEBUG
NSLog(@"preparing to press button!");
#endif
[self prepareForButtonPress];
#if DEBUG
NSLog(@"pressing button!");
#endif
[self activatePressButtonSequence:self withCompletion:^{
#if DEBUG
NSLog(@"button sequence complete.");
#endif
[self buttonPowerDown];
}];
NSLog(@"This line has no DEBUG macro, so it gets printed in both debug and release builds!");
}今のXcodeではDEBUGマクロはデバッグビルドで有効になる。
で、このQAからNSLogの便利情報がいろいろ見つかった。
まずはNSLogで指定できるフォーマット
この前に紹介した z とかの解説あり。公式ドキュメントはここにあったのか。
この中に Platform Dependencies というのがある。
そうか NSInteger の正式フォーマットは %ld or %lx なのか。NSUIntegerは %lu or %lx。%lx が良さそう。
さらにポインタが %p or %zx であることが判明。%xでワーニングが出てて悩ましかったのがこれで解決。
さらに __LINE__ や __PRETTY_FUNCTION__ の公式情報など。
他にも有用なリンクがまとめられていた。





