I haven’t found any get equivalent to appendBytes. If I’ve understood getBytes correctly, that method always returns bytes from the start of the buffer. It will not increment.
What’s the reason for this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are several methods that give you access to some part of the data in a NSData object. For example, you can use
-getBytes:range:to copy the data specified by a NSRange into a buffer. Or you can use-subdataWithRange:to get a NSData that contains just a portion of another.If you want to read sequentially through the contents of a NSData object, you can create a NSInputStream and initialize it with your NSData, and then read from the stream using
-getBuffer:length:or-read:maxLength:.Note: you obviously don’t need the
whileloop in the code above if you’re not doing the same thing to each chunk of data that you read — I just included it because it’s a common way to read data.