const unsigned char *rawImgNSDataBuffer=(unsigned char *)[self.RNGbyImage.rawImgNSData bytes];

I am attempting to read my NSData by calling the method - (const void *)bytes. What I did is assign the returned bytes to my own unsigned char pointer, so as to read bytes inside rawImgNSData from this pointer rawImgNSDataBuffer. However, the returned pointer rawImgNSDataBuffer has always 0 contents. It is not nil, but it never contains char values I expect. I would guarantee that my NSData is not nil and NSData has length > 0. I was trying hard to read it but not worked. Any help would be much appreciated.

有帮助吗?

解决方案

If your rawImgNSDataBuffer is not nil, then things should be working fine. What do you mean that it has 0 contents? Are you viewing it in the debug area?

If you're printing out the contents and it displays nothing, it may just mean that the first bytes are '00' which in terms of char type, just means end of a string. However, it doesn't mean that there is no data there.

I suggest placing a breakpoint after your bytes call, then right-clicking on the rawImgNSDataBuffer variable in the debug area and selecting "View Memory of "rawImgNSDataBuffer"". You'll get a better picture of what the data actually looks like there.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top