I have a problem with a function.
I want to send bytes to through a tcp socket.
However I have not figured out how to do that as I get warnings that my types don’t machs
here’s the code:
This is in the application viewcontroller:
-(IBAction) sendClicked:(id)sender{
Byte sendBuffer[10];
sendBuffer[0]=1;
sendBuffer[1]=0;
sendBuffer[2]=1;
sendBuffer[3]=0;
sendBuffer[4]=1;
sendBuffer[5]=0;
sendBuffer[6]=0;
sendBuffer[7]=1;
sendBuffer[8]=0;
sendBuffer[9]=1;
if(tcp) [tcp sendData: *sendBuffer]
}
and this is in the tcp.m file:
-(void) sendData: (Byte*) sendBytes {
NSData *data;
memcpy(data,sendBytes,200);
[socket writeData: data withTimeout:-1 tag:0];
sendBuffer=nil;
}
Should I use NSMutablearrays instead?I admit, I am a beginner. Hope someone can help me.
The problem is that
*sendBufferrefers to the firstBytein thesendBufferarray. Try this:Oh, and you’re missing a semicolon.