문제

I need to convert a NSData object to an NSString. It is meant to be gibberish but I need it for debbuging.

When I use NSString's initWithData, it breaks as the data has NULL bytes. How can I make it ignore the null bytes and get a proper string?

도움이 되었습니까?

해결책

Copy the NSData to a NSMutableData, byte by byte, skipping any null bytes. Then initialise the string from that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top