c_cpp 用于生成十六进制字符串表示的NSData类别
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 用于生成十六进制字符串表示的NSData类别相关的知识,希望对你有一定的参考价值。
//
// Copyright © 2012 Yuri Kotov
//
#import "NSData+ADVHexadecimalRepresentation.h"
@implementation NSData (ADVHexadecimalRepresentation)
- (NSString *) hexadecimalRepresentation
{
const char *bytes = [self bytes];
NSUInteger length = [self length];
NSMutableString *string = [NSMutableString stringWithCapacity:(2 * length)];
for (NSUInteger i = 0; i < length; ++i)
{
[string appendFormat:@"%02hhx", bytes[i]];
}
return string;
}
@end
//
// Copyright © 2012 Yuri Kotov
//
#import <Foundation/Foundation.h>
@interface NSData (ADVHexadecimalRepresentation)
- (NSString *) hexadecimalRepresentation;
@end
以上是关于c_cpp 用于生成十六进制字符串表示的NSData类别的主要内容,如果未能解决你的问题,请参考以下文章