当前位置:网站首页>Nslog output Chinese
Nslog output Chinese
2022-07-21 03:33:00 【Blue se cornflower】
Xcode In print log When , Chinese will be converted into hexadecimal encoding output , Inconvenient to view , Most of the solutions on the Internet are to rewrite the following method :
- (NSString *)descriptionWithLocale:(nullable id)locale indent:(NSUInteger)level;
When the nested format of data is deep , If this printing method is not formatted , It is difficult to see the hierarchical structure of data , If you want to print data by indenting levels , The code is a little more complicated . Here is another implementation found on the Internet , After testing, it is found that it is easy to use , Share here .
- establish NSArry and NSDictionary Of category.
- stay .m Add the following code to .
+ (void)load {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
hc_swizzleSelector([self class], @selector(descriptionWithLocale:indent:), @selector(hc_descriptionWithLocale:indent:));
});
}
- (NSString *)hc_descriptionWithLocale:(id)locale indent:(NSUInteger)level {
return [self stringByReplaceUnicode:[self hc_descriptionWithLocale:locale indent:level]];
}
- (NSString *)stringByReplaceUnicode:(NSString *)unicodeString {
NSMutableString *convertedString = [unicodeString mutableCopy];
[convertedString replaceOccurrencesOfString:@"\\U" withString:@"\\u" options:0 range:NSMakeRange(0, convertedString.length)];
CFStringRef transform = CFSTR("Any-Hex/Java");
CFStringTransform((__bridge CFMutableStringRef)convertedString, NULL, transform, YES);
return convertedString;
}
static inline void hc_swizzleSelector(Class theClass, SEL originalSelector, SEL swizzledSelector) {
Method originalMethod = class_getInstanceMethod(theClass, originalSelector);
Method swizzledMethod = class_getInstanceMethod(theClass, swizzledSelector);
BOOL didAddMethod =
class_addMethod(theClass,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(theClass,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
Be careful : Because the runtime is used , So you need to add a header file .
#import <objc/runtime.h>
边栏推荐
- 【深度学习】怎么为模型选择正确的最后一层激活和损失函数
- Redis主从复制
- MIMO-OFDM Wireless Communication Technology and matlab implementation (2) - Outdoor channel model under SISO
- Flink-时间语义
- (7) Pytorch deep learning: full connection layer network
- innobackupex参数说明
- 根据不同configuration加载不同的plist文件
- (三)PyTorch深度学习:反向传播梯度下降
- Li Hongyi 2020 machine learning -- p17 CNN & P 14
- (二)PyTorch深度学习:梯度下降
猜你喜欢
论文学习---Non-parametric Statistical Learning for URLLC Transmission Rate Control
Redis五种基本数据类型(超级详细)
Load different plist files according to different configurations
数仓基本概述
MIMO-OFDM Wireless Communication Technology and matlab implementation (2) - Outdoor channel model under SISO
Paper reading -- risk resistant resource allocation for embB and urllc coexistence under m/g/1 queuing model
Centos8 (Linux) 安装 redis
Non parametric statistical learning for urllc transmission rate control
李宏毅机器学习2020---P12 Brief introduction of DL & P15 Why DL
(9) Pytorch deep learning: convolutional neural network (the inception module in googlenet network architecture is this convolutional neural network architecture)
随机推荐
Spark SQL 案例(一)
Mysql 主从复制 docker集群搭建
Li Hongyi machine learning 2020---p12 brief introduction of DL & p15 why DL
Centos8(linux)安装mysql8.0.28
TPCC performance test of Dameng database
Flink SQL自定义解析 Map和Array数据类型
MIMO-OFDM无线通信技术及MATLAB实现(2)-SISO下的室外信道模型
The insertion order of single chain storage structure
Package (.Py) files into (.Exe) files in pychart
(6) Pytorch deep learning: logistic regression (multi-layer and multi-dimensional feature input)
(七)PyTorch深度学习:全连接层网络
Select all on the current page of Ali vector Gallery
Flink SQL custom parsing map and array data types
(六)PyTorch深度学习:加载数据集
单链式存储结构 插入顺序的问题
Dameng DEM deployment
[deep learning] how to select the correct activation and loss function of the last layer for the model
docker 远程连接 mysql
dm_ svc. Conf configuration
Flink DataStream API (十四)Flink 输出到 MySQL(JDBC)