高效开发 --> Console 小 Tip

Running 自动切换最大化 Console

  1. 打开 Tab Bar 显示:View – Show Tab Bar.
  2. 新建Tab 并双击改名:Command+T 改名Console
  3. 将Console拖动至第一位置选中后将Console拉到最大化
  4. 激活 Console 显示,View – Debug Aera – Activate Console,或者直接 Command+Shift+C.
  5. Command+, 进入 Preferences – Behaviors, 在 Running里选中 Start 后 勾选 Show Tab named,填入刚才设置的Tab名字 Console
  6. 选中第二个Tab 再次Running 就会自动切换到最大化的Console

Tip:Command+Shift+[/] 切换 Tab 快捷键。

Console 输出 Log 时将 Unicode 转为中文

  1. 在项目中新建.m文件 (Foundation+Log.m)
  2. 将以下代码放进去就OK了。
@implementation NSDictionary (Log)
- (NSString *)descriptionWithLocale:(id)locale
{
    NSMutableString *string = [NSMutableString string];
    
    // 开头有个{
    [string appendString:@"{\n"];
    
    // 遍历所有的键值对
    [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        [string appendFormat:@"\t%@", key];
        [string appendString:@" : "];
        [string appendFormat:@"%@,\n", obj];
    }];
    
    // 结尾有个}
    [string appendString:@"}"];
    
    // 查找最后一个逗号
    NSRange range = [string rangeOfString:@"," options:NSBackwardsSearch];
    if (range.location != NSNotFound)
        [string deleteCharactersInRange:range];
    
    return string;
}
@end

@implementation NSArray (Log)

- (NSString *)descriptionWithLocale:(id)locale
{
    NSMutableString *string = [NSMutableString string];
    
    // 开头有个[
    [string appendString:@"[\n"];
    
    // 遍历所有的元素
    [self enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
        [string appendFormat:@"\t%@,\n", obj];
    }];
    
    // 结尾有个]
    [string appendString:@"]"];
    
    // 查找最后一个逗号
    NSRange range = [string rangeOfString:@"," options:NSBackwardsSearch];
    if (range.location != NSNotFound)
        [string deleteCharactersInRange:range];
    
    return string;
}
@end

你可能感兴趣的:(高效开发 --> Console 小 Tip)