2013-11-25 1 views
-1

난 이진 데이터를 포함하는 OCTET_STRING_t 있습니다. ASN1C를 사용하여 애플의 앱 스토어 영수증 데이터를로드 중입니다. 다음은 몇 가지 예제 코드입니다.OCTET_STRING_t를 NSData로 변환 하시겠습니까?

// Walk the attributes 
for (i = 0; i < payload->list.count; i++) { 
    ReceiptAttribute_t *entry = payload->list.array[i]; 
    switch (entry->type) { 
     case 5: // 5 = hash 
     OCTET_STRING_t *hash = &entry->value; 
     break; 
     ... 
    } 
} 

NSData 컨테이너로 변환하는 올바른 방법은 무엇입니까? OCTET_STRING_t 가정

답변

0

는 간단히 this one 동일하다 :

OCTET_STRING_t *hash = &entry->value; 
NSData *data = [[NSData alloc] initWithBytes:hash->buf 
             length:hash->size];