From dbab6ab54c40a016f75e75a4143576c3fa41c3e0 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 1 Oct 2019 17:29:46 +0300 Subject: Drop AFNetworking and SSKeychain --- Juick/Helpers/NSData+Hex.h | 19 +++++++++++++++++++ Juick/Helpers/NSData+Hex.m | 22 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 Juick/Helpers/NSData+Hex.h create mode 100644 Juick/Helpers/NSData+Hex.m (limited to 'Juick/Helpers') diff --git a/Juick/Helpers/NSData+Hex.h b/Juick/Helpers/NSData+Hex.h new file mode 100644 index 0000000..bd8e519 --- /dev/null +++ b/Juick/Helpers/NSData+Hex.h @@ -0,0 +1,19 @@ +// +// NSData+Hex.h +// Juick +// +// Created by Vitaly Takmazov on 01/10/2019. +// Copyright © 2019 com.juick. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface NSData (Hex) + +- (NSString *)hexString; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Juick/Helpers/NSData+Hex.m b/Juick/Helpers/NSData+Hex.m new file mode 100644 index 0000000..243a380 --- /dev/null +++ b/Juick/Helpers/NSData+Hex.m @@ -0,0 +1,22 @@ +// +// NSData+Hex.m +// Juick +// +// Created by Vitaly Takmazov on 01/10/2019. +// Copyright © 2019 com.juick. All rights reserved. +// + +#import "NSData+Hex.h" + +@implementation NSData (Hex) +- (NSString *)hexString { + NSMutableString *string = [NSMutableString stringWithCapacity:self.length * 3]; + [self enumerateByteRangesUsingBlock:^(const void *bytes, NSRange byteRange, BOOL *stop){ + for (NSUInteger offset = 0; offset < byteRange.length; ++offset) { + uint8_t byte = ((const uint8_t *)bytes)[offset]; + [string appendFormat:@"%02x", byte]; + } + }]; + return string; +} +@end -- cgit v1.2.3