2012-09-28 3 views

답변

1

나는에 배열에

NSMutableData * rawData = [[NSMutableData alloc] initWithData:data]; 
    NSMutableArray * networkBuffer = [[NSMutableArray alloc]init]; 

    const uint8_t *bytes = [self.rawData bytes]; 

    //cycle through data and place it in the network buffer 
    for (int i =0; i < [data length]; i++) 
    { 
     [networkBuffer addObject:[NSString stringWithFormat:@"%02X", bytes[i]]]; 
    } 

다음 물론 당신은 그냥 조정할 수있는 개체를 캐스팅 : 나는 다음과 같은 시도 귀하의 networkBuffer (nsmutablearray)

5

그러나 컴파일러가 큰 소리로 외쳐지는 ...

mutableBytes*void*을 반환하기 때문입니다. 문제를 해결하기 위해 char*에 캐스트 :

((char*)[mValues mutableBytes])[0] = v; 

또한 사용할 수 replaceBytesInRange:withBytes:

char buf[1]; 
buf[0] = v; 
[mValues replaceBytesInRange:NSMakeRange(0, 1) withBytes:buf]; 
관련 문제