Doarchive

[ObjectiveC] Converter Data to String NSData 를 NSString으로 변환 본문

Mobile/iOS

[ObjectiveC] Converter Data to String NSData 를 NSString으로 변환

오순발닦개 2020. 11. 24. 15:22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
uint8_t *receivecData = (uint8_t*)[data bytes];
 
    NSString *receivecStr;
 
    
 
    const unsigned char *dbytes = [data bytes];
 
        NSMutableString *hexStr =
 
           [NSMutableString stringWithCapacity:[data length]*2];
 
        int i;
 
        for (i = 0; i < [data length]; i++) {
 
            [hexStr appendFormat:@"%02x ", dbytes[i]];
 
        }
 
    receivecStr = [NSString stringWithString: hexStr];
cs

 

728x90