NSLog(@"%s", __func__);
NSLog(@"%s %d", __PRETTY_FUNCTION__, __LINE__);
NSLog(@"scrollView: %@", NSStringFromCGRect(scrollImageView.frame));
NSLog(@"imageView: %@", NSStringFromCGRect(selectPointImageView.frame));
NSLog(@"zoomScale: %@", @(scrollImageView.zoomScale).stringValue);
UIKIT_EXTERN NSString *NSStringFromCGPoint(CGPoint point);
UIKIT_EXTERN NSString *NSStringFromCGSize(CGSize size);
UIKIT_EXTERN NSString *NSStringFromCGRect(CGRect rect);
UIKIT_EXTERN NSString *NSStringFromCGAffineTransform(CGAffineTransform transform);
UIKIT_EXTERN NSString *NSStringFromUIEdgeInsets(UIEdgeInsets insets);
UIKIT_EXTERN NSString *NSStringFromUIOffset(UIOffset offset);
UIKIT_EXTERN CGPoint CGPointFromString(NSString *string);
UIKIT_EXTERN CGSize CGSizeFromString(NSString *string);
UIKIT_EXTERN CGRect CGRectFromString(NSString *string);
UIKIT_EXTERN CGAffineTransform CGAffineTransformFromString(NSString *string);
UIKIT_EXTERN UIEdgeInsets UIEdgeInsetsFromString(NSString *string);
UIKIT_EXTERN UIOffset UIOffsetFromString(NSString *string);
NSLog(@"AlbumName(new): %@", albumName);
for (id key in [dict keyEnumerator]) NSLog(@"Key:%@ Value:%@", key, [dict valueForKey:key]);
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ダウン時のスタックトレース
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
.....
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
}
void uncaughtExceptionHandler(NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}
出力例:
2013-06-08 14:27:49.153 Test[29884:11303] Stack Trace: (
0 CoreFoundation 0x01c9002e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x010cde7e objc_exception_throw + 44
2 CoreFoundation 0x01c321c4 -[__NSArrayM removeObjectAtIndex:] + 212
3 Test 0x000020bb -[MyViewController remove] + 91
4 Foundation 0x00acb5b3 __NSFireDelayedPerform + 380
.....
)
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
連想配列のキー&クラス名を表示する
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- (void)logClassNameOfKeyElement:(NSDictionary *)dic
{
for (id key in [dic keyEnumerator]) {
NSLog(@"Key:%@ Value:%@ Class:%@", key, dic[key], [dic[key] class]);
}
}
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ipa作成時、ログ出力抑制
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#ifdef NS_BLOCK_ASSERTIONS
#ifndef NSLog
#define NSLog( m, args... )
#endif
#else
#ifndef NSLog
#define NSLog( m, args... ) NSLog( m, ##args )
#endif
#endif
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
フォーマット書式
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
%@ NSString
%d,%D,%i 整数
%u,%U 符号なしの整数
%x 符号なし整数を小文字の16進で表現
%X 符号なし整数を大文字の16進で表現
%f 小数
%c 文字
%s C言語の文字列
%% %
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
NSIntegerのフォーマット指定はlong
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
NSInteger i;
NSLog(@"%ld", (long)i);
以下は64bitでコンパイルするとWarningになる。
NSInteger i;
NSLog(@"%d", i);
以下は32bitでコンパイルするとWarningになる。
NSInteger i;
NSLog(@"%ld", i);
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
落ちた時のStackTrace
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
.....
NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);
}
void uncaughtExceptionHandler(NSException *exception) {
NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}
出力例:
2013-06-08 14:27:49.153 Test[29884:11303] Stack Trace: (
0 CoreFoundation 0x01c9002e __exceptionPreprocess + 206
1 libobjc.A.dylib 0x010cde7e objc_exception_throw + 44
2 CoreFoundation 0x01c321c4 -[__NSArrayM removeObjectAtIndex:] + 212
3 Test 0x000020bb -[MyViewController remove] + 91
4 Foundation 0x00acb5b3 __NSFireDelayedPerform + 380
.....
)
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
SubView調査用
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
for (UIView *view in self.view.subviews) {
NSString *className = NSStringFromClass([view class]);
NSLog(@"className: %@", className);
}
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
SubView調査用
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
- (BOOL)enumSubviews:(UIView*)view withNest:(int)idx
{
Class cl = [view class];
char sp[255];
memset(sp, ' ', 255);
sp[idx*4] = 0;
NSLog(@"%s%@\n", sp, NSStringFromClass(cl));
for (int i = 0; i < [view.subviews count]; i++)
{
if ([self enumSubviews:[view.subviews objectAtIndex:i] withNest:idx+1])
return YES;
}
return NO;
}
最終更新:2018年02月26日 14:01