I have a C# code, which copy bytes to a byte Array, from specific index, as following example illustrates:
string headerInfo = String.Format(source + "<>" + destination + "<>" + sessionId);
headerInfo = headerInfo.TrimEnd('\n', '\0', '\r');
byte[] headerInfoBytes = Encoding.UTF8.GetBytes(headerInfo);
byte[] headerInfoLength = BitConverter.GetBytes(headerInfo.Length);
//create an byte Array with proper size.
byte[] sendData = new byte[4 + 4 + headerInfoBytes.Length + dataContractBytes.Length];
headerInfoLength.CopyTo(sendData, 0);
dataContractLengthBytes.CopyTo(sendData, 4);
headerInfoBytes.CopyTo(sendData, 8);
dataContractBytes.CopyTo(sendData, 8 + headerInfoBytes.Length);
m_clientSocket.Send(sendData);
my question is, how I can achive the CopyTo in objective c way?
Check out this guide on how to handle mutable data.
If you specifically need the index part, you can use
replaceBytesInRange:withBytes:. Otherwise, just append the data: